- Home /
Memory leak using bundles.
Hi, after some problems with memory in my game, i have done a little test, loading and unloading all my bundles, loading all assets and then destroying. With this, i have tracked the memory usage, and until now ( yes the code still running and opening all my asset bundles ) there's a leak of 225 MB! could it be something that i forgot to unload? something wrong with this code? i have done all that i could think to fix this leak, but nothing worked :(
Obs: No Scripts are attached to them.
// Update is called once per frame IEnumerator LoadThemAll() { int count = _bundles.Count; // my list of bundle paths int act = 0; WaitForSeconds waitSeconds = new WaitForSeconds(1); AssetBundle b; while (true) { Debug.Log(pathlist[act]); WWW www = new WWW(pathlist[act]); while (!www.isDone) { yield return 0; }
b = www.assetBundle;
Object[] objs = b.LoadAll();
foreach (Object o in objs)
{
if (o == null)
continue;
Object r = Instantiate(o);
yield return waitSeconds;
Destroy(r);
Debug.Log(string.Format("---->{0}", o.name));
if (o != null)
DestroyImmediate(o, true);
}
b.Unload(true);
Destroy(b);
www.Dispose();
AsyncOperation op = Resources.UnloadUnusedAssets();
while (!op.isDone)
yield return 0;
GC.Collect();
act++;
if (act == count)
act = 0;
}
}
Thanks. :)
Answer by Pedro.du · Dec 10, 2010 at 10:18 PM
What Unity version?
it was the 2.6, i have done some other tests and I discovered that this only occurs in the Editor, then i just stopped trying to resolve this by now.
Thanks :)
Your answer
Follow this Question
Related Questions
Asset bundle memory leak and exception 1 Answer
Unloading asset bundles doesn't clear memory on iOS 1 Answer
Asset Bundle Limitations 0 Answers
Mesh Destroy After an Editor Stop 0 Answers
Assetbundle memory leaks 0 Answers