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. :)