- Home /
Memory Leak by www?
My test code here:
IEnumerator StartDownLoad(string url)
{
WWW www = new WWW(url);
yield return www;
www.Dispose();
www = null;
Resources.UnloadUnusedAssets();
}
Run in webplayer(IE8/Firefox) and I find that :
after the function was called, the memory cost increased 30M+ in Windows Task Manager.
(the url points to a big assetbundle)
Why is the memory increased after dispose?
Is there any thing wrong in my code?.
(In Unity IDE, the memory show in Profile dose not changed after the function called)
You may need to post the code that calls that function. It could be getting called repeatedly or not making it to the Dispose. Also be careful about using the task manager to judge how memory if being used in an application. Unity may need to load extra stuff when it uses www and then it keeps it "hot" so it doesn't have to load it again if you use that function. I don't really know that it does that but it is just to illustrate that A LOT of stuff is done with RA$$anonymous$$ that is out of your control.
the code to call the function is simple:
if(GUI.Button()){StartCoroutine(StartDownLoad)}
I'm sure the function was called once.(test by debug.log)
yes. the memory never decreased until i close the browser. I tried many times all get the same result.
unity vertion: 3.5.0f2 (my friend who use 3.5.2 f2 get the same result)
You could try to clean the heap with System.GC.Collect(); and see if it helps. $$anonymous$$eep in $$anonymous$$d that is quite expensive function, try to use it when you would have a break in your game.
Answer by zzb · Jun 25, 2012 at 03:13 AM
I think you should try to use www.assetBundle.Unload(true);
Your answer
Follow this Question
Related Questions
IOS memory leak because of WWW object 1 Answer
UnityWebRequest leaking memory. 2 Answers
Assetbundle memory leaks 0 Answers
Unload asset loaded with WWW class 1 Answer