- Home /
Prevent 'Cleaning up leaked objects'
I've been running into this problem with Unity 3.4 on OS X, and searching for this error message only reveals that it's supposed to be a harmless optimization. My problem is that it's NOT harmless, as the "leaked" objects are not actually leaked. Here's the full message:
Cleaning up leaked objects in scene since no game object, component, or manager is referencing them
X has been leaked Y times.
Here are two examples where I get this log message in relation to objects NOT in the scene being wrongfully destroyed:
I have a ScriptableObject that contains an array of other ScriptableObjects which are not referred to in any other place. When saving the scene, the other ScriptableObjects disappear.
I have a prefab with a dynamically built mesh. When saving the scene I get this message, and the mesh is lost from the MeshFilter component.
In all cases, I get the same message every time I save and the object(s) are not destroyed until the next play test or if the scene is reloaded. After that the objects are lost and the message doesn't appear for future saves.
My questions: How can I disable this "feature"? Is this a bug in Unity or am I doing something wrong?
you would need to write code to save objects created during runtime
by it's nature anything created during runtime exists only within the runtime scope as it were
thats not a bug. thats proper garbage collection.
if it saved it you could end up with it in memory even after the program ended clogging up resources used by the system.
It's not a bug and it should not be turned off. You should save a mesh into resources folder or something, a hard save and thereby remove it from RA$$anonymous$$ memory and keep it in the hard drive. It's not a bug it's that your trying to do it in an unsafe way.
Answer by Immanuel-Scholz · Jun 29, 2013 at 08:40 PM
I think you should look at your hideFlags for the auto-generated stuff. If you want to re-create them every time anyway, they most probably should be "`DontSave`" or even "`HideAndDontSave`".
I recommend this talk to get a found understanding of the serialization system: http://www.youtube.com/watch?v=MmUT0ljrHNc
Your answer
Follow this Question
Related Questions
terrain game no scene 0 Answers
3d object in 2d scene 1 Answer
Asset Server Team and project management Unity Pro 2 Answers
How top create prefab with simple cube using YAML? 1 Answer
How to Merge Scene with Asset Server 0 Answers