- Home /
Downloaded file consumes a large amount of memory iOS
Hi all,
I am building an application that needs to download some large files at startup. I'm using UnityWebRequest to get the file, then saving it to a subfolder of Application.persistentDataPath.
After the download is completed, there is a really large chunk of memory that continues to be used until the app restarts, and on older iOS devices with less memory this causes a crash with a memory warning. However, when I restart the app, the memory usage is back down to normal levels and the app performs just fine.
So, does UnityWebRequest store its downloaded data in memory? If so, can I free that memory manually afterwards?
Answer by Casiell · Oct 01, 2019 at 07:51 AM
I believe you have to manually call Dispose when you are done with a UnityWebRequest
I'm doing that for every download I do -- I use UnityWebRequest.Send() with a custom DownloadHandlerScript, then once the file has finished downloading the DownloadHandlerScript fires an OnComplete event that the web request's class subscribes to, calling the Dispose() method.
And are you disposing the file itself? Could you share the fragment where you actually download the file?