Writing www.bytes to disk leaks memory on iOS

Hello,

Writing www.bytes to disk leaks memory on iOS.

Mentioned:

http://answers.unity3d.com/questions/938707/does-applicationcapturescreenshot-leak-memory-ios.html
With no responses or solutions aside from not using WWW.

Unfortunately, our backend setup does not allow us to do a Socket connect in that fashion. The only other solution I see is writing a plugin for Android and iOS specifically… which is something I would like to avoid. This seems like a very critical issue.

How to Reproduce:

1.) Host a file somewhere (something of size, like a Texture or Asset Bundle).

2.) Write something like this:

public IEnumerator Coroutine()
{
WWW www = new WWW("endpoint");

yield return www;

System.IO.File.WriteAllBytes("path", www.bytes);

www.Dispose();

//Extra Cleanup just because
www = null;
Resources.UnloadUnusedAssets();
}

3.) Run on device and observe a memory leak

I have created a support ticket with no response so far. Is there something I’m missing? If I’m not, is this something that is going to be fixed soon?

Running on Unity 4.6.4p3

2 Likes

I’m using Unity 5.0.1f1 and I have the same problem. Any solution?

Hey Ataru04,

Not yet… I was working on porting our stuff over to Unity 5 on the back-burner and it’s really disappointing to learn that this issue might live on in Unity 5.

I’m going to experiment with an iOS plugin as soon as I get some bandwidth. If I get anywhere I’ll post what I did here. I’ll eventually have to make an Android plugin as well.

This seems like a huge issue and I imagine I’m not the only one who has a product crippled to an un-shippable state due to this…