Hey guys, got a few questions about memory management I was hoping to get some clarification on.
First off, I’ve been doing some testing with the “DetectLeaks” script on the wiki and found that when I move between scenes, some assets that were used in the previous scene will still be loaded in memory. For example, when I transition from the main menu to a game level with LoadLevel, I find that Unity still has several texture atlases from the main menu loaded in memory, like MainMenuAtlas, OptionsAtlas, LevelSelectAtlas, etc. Shouldn’t these be unloading on the scene change? And more importantly, am I doing something wrong to cause this?
Second, I’ve heard that using Resources.Load may be a bad idea because it requires a constant memory presence. Would this still be a problem if I’m only loading in prefabs that reference other prefabs? For example, I have a prefab in Resources called “GlobalPrefabs” that only contains references to other prefabs in my project. Then, when I start the game, I have easy access to a list of prefabs that I can use for instantiation throughout the game. But doing this doesn’t load all the prefabs referenced by the Resources prefab into memory as well does it? That would mean the difference between my GlobalPrefabs object taking up a few kb and up to several mb.
Thanks!