- Home /
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.
Answer by aeau2012 · Nov 22, 2013 at 02:55 PM
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:
Resources.UnloadUnusedAssets();
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 http://docs.unity3d.com/Documentation/ScriptReference/Resources.UnloadUnusedAssets.html
and then force the garbage collector to pass to remove all this accumulated memory:
System.GC.Collect();
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!
Thanks for the reply aeau2012
I A$$anonymous$$ already using that method for clearing things away after reloading the shell front end BUT a lot of the assets that are used in game, in fact, $$anonymous$$OST, are NOT stored in the Resource folder.
I'll have to have a word with the $$anonymous$$m and find out why that decision was made and see what I can do to correct things, so thanks very much for the headsup.
I am wondering though........ is there no other way of applying the same mechanism that Resources.UnloadUnusedAssets() uses to clear away all those other objects?
I'm not looking for an easy-out as much as I am wishing to find out more about the difference in the way that files are managed in each case.