Object references listed in profiler but not in hierarchy.

Ok, here’s the thing.

Memory usage when starting game and entering a certain page of the shell GUI <> 150MB.

All object references at this point make complete sense. Everything that’s there can be accounted for in the current context.

I enter the game and then immediately quit and return to the shell GUI page I was at previously. I check the memory usage and it’s risen by 30MB.

I check the referenced objects. MANY of these are now from the in-game scene with reference counts of 1 or a few which can be attributed to their own internal components, but NO references from the current hierarchy which is now reflecting the expected state of the front-end scene.

I’d REALLY like to get my memory usage at this point back down to where it was before I entered the game because this overhead is causing issues on low-spec devices like the iPod touch 4G and original iPad.

So if anyone can suggest any strategies for finding where the root of this inconsistency lies, that would be amazing.

Thanks in advance.

Hey RobBrooks, are you making instances of prefabs in the other scene? if it so, are your instance in the folder Resources?

If the answer is yes, then at the start of your scene of GUI, you should put:


This will unload all the assets that are not being used, for they to be unused, unity
goes trough all your gameobjects in the hierarchy, if the assets are not there unity unloads Unity - Scripting API: Resources.UnloadUnusedAssets

and then force the garbage collector to pass to remove all this accumulated memory:


If the answer is that your instance are not from Load.Resources, then you should start doing it as a good practice.

Hope this help you!