What happens to “new” objects when switching from one level to another?
Does the Unity garbage collection handle loose ends when switching levels? What documentation is there on the subject?
Thanks CSDG
What happens to “new” objects when switching from one level to another?
Does the Unity garbage collection handle loose ends when switching levels? What documentation is there on the subject?
Thanks CSDG
All objects are garbage collected if they are not referenced by anything. This is standard behaviour for managed environments. Look up .net garbage collection and the GC class.
Oh. Now I feel like a dingus for not seeing that. So I guess I should reimport my model then, eh?
– DordusRisingWhile experimenting with several Global Functions, OnEnable(), OnDisable() and OnDestroy(), I had noticed that these three functions are called depending if entering or exiting a scene (level). I assume I would use OnDestroy() to null all textures and all objects created using the “new” keyword. Is this the appropriate way of cleaning up the scenes (levels) even though we may switch back and forth to the same levels!?
Since I am using the free version and do not have access to any of Unity’s profiling tools, I have been using the performance tools from xcode, specifically the ObjectAlloc.tracetemplate along with its Memory Leaks. I was just wondering if there other methods to pin point the memory leaks that may be better than what I am presently using.
Thanks CSDG
If those textures you are creating are all unity objects (and they should be!) then you shouldn’t need to do anything to them at all. OnDestroy() is more for when you want your scene to react to the destruction of the object in a game world sense.
I was looking for a way to finalize references to instantiated objects. In C#, the unity documentation discourages using class constructors and finalizers. When I switch to another level (scene), how do I dereference (cleanup) the instantiated objects (non-Monobehaviour objects) before entering another level?
– UniteMage
[206769-fbx-export-transform.jpg|206769]
– dk404