Sorry if you find that sentence in my long post where I’m trying to be helpful condescending.
So you’re trying to fit within the spec of a specific console. (this is why I was asking what you’re attempting to do, we don’t know your situation)
So my answer still stands the same. The numbers aren’t going to be perfectly accurate. And the negatives just come from the way that behind the scenes a lot more goes on with memory management then you would expect. The closest you’ll get is a estimate since the actual memory a scene takes up can vary depending on what’s going on in the scene (unless you have very static scenes… which games tend not to have).
So yeah. As I said before. Create a clean scenario where you just load a scene individually. Check your memory there. Do this for every scene and get a rough idea of what each scene takes up.
You can even run the profiler (which can be ran remotely too) which can report more specifics on the memory usage.
And in the end you’ll still need to operate at min/maxes here (sorry I didn’t know what platform you’re targeting, it’s why I asked what you’re attempting to do). Because that’s how dynamic games work. You need to locate your mins and maxes. It’s not just when the level loads, it’s when you’re in the heat of a battle scene and a swarm of enemies are being spawned. Or it’s when you leave your game on for hours on end in the same level because the player is exploring, but lost, and you need to catch any errant leaks.
…
Anyways… back to your original question though of why you some times see negatives. It’s because memory management is more complex than just the assets in the scene. And sometimes during loading/and unloading more or less memory may be needed for various tasks since not just assets take up memory. So does the code that creates the code objects that do the tasks involved with loading/unloading the assets.
As a result you can’t rely on the method you’re using to get reproduceable exact results of memory as the dynamics of a game environment change. That is unless you created a perfectly determinate game (which is difficult in unity since it’s not designed to be determinate… but that isn’t to say it’s impossible, you can make specific aspects of your game determinate).
So instead I was attempting to offer other ways to approach your problem, but had to from a limited set of information as I do not know your game, your target, or your specific situation. This is what I was highlighting by asking what you’re actually doing… you intentionally left out information in your own code you posted, this doesn’t help, it hurts, as we now need to guess what you’re doing. We now have to guess why you’re seeing what you’re seeing. The memory differences could be because of how things work behind the scenes, or it could be a result of how you implement what you changed out for comments. We don’t know, there’s no way for us to know, since you hid that information.
It’s also why my posts become so long as I try to cover my bases… but I can’t cover them all without having a 3 year long post. So we end up missing things like you’re on PS4.
More information is better. Else you’ll get guesses like Gozzler gave, people who don’t even respond, or long blargh posts like my own. Which boils down to “that sucks that it’s not doing what you want, but maybe this will help? Not sure, but maybe?”
Anyways, to sum up, I wish you luck. And if you want, you can maybe give us some specifics about your game scenes and we may be able to give you an idea of what are hot spots you should look into when QA’ing your levels. But I also understand if you don’t want to share specifics of your game (or maybe even can’t because of contract or soemthing).