- Home /
AssetBundles on iOS: Memory always increases, causing crash
We have our asset bundles stored on an Amazon S3 bucket. When the game starts, it determines which bundles it needs to download new versions of, using WWW.LoadFromCacheOrDownload.
The problem we're running into is the memory iOS reports it has allocated for our app keeps increasing, however the memory Unity reports it's using (through the profiler) always stays the same. We have enough bundles that by the time it has finished downloading everything we need, it has invariably received a memory warning from iOS, and we are shutdown due to memory pressure shortly after.
Common solutions we have in place already: Unloading the assetbundle after the WWW is finished, using assetBundle.unload(), calling Resources.UnloadUnusedAssets(), and calling Dispose() on the WWW. None of it is solving the problem.
Code follows:
private IEnumerator DownloadBundle(DownloadQueueEntry entry, DownloadFinishedCallback callback)
{
while (!entry.finished)
{
// grab bundle off S3
string url = string.Format(BUNDLE_URL_FORMAT, entry.directory, entry.assetName);
WWW www = WWW.LoadFromCacheOrDownload(url, entry.version);
yield return www;
if (string.IsNullOrEmpty(www.error))
{
Debug.Log("[BundleDownloader] Download Completed " + entry.assetName);
entry.finished = true;
entry.downloading = false;
www.assetBundle.Unload (true);
Resources.UnloadUnusedAssets ();
}
else
{
// usually timed out resolving host, just try again for now
Debug.LogError("[BundleDownloader] Download failed: " + url + " Error: " + www.error);
}
www.Dispose();
www = null;
}
if(callback != null)
{
callback ();
}
}
A screenshot showing the increasing memory usage is at the link below. Memory usage proceeds like that until it has chewed up around 150MB. This is all in an scene that only has a GameObject for init scripts in it (no art or anything).
https://www.dropbox.com/s/3b6skexz6xhug5g/Screenshot%202014-03-28%2014.54.26.png
Hi,
The post is old but I'm actually facing the exact same situation. How did you solve it ?
Hey guys,
Sorry for the long silence. We were never able to solve it ourselves, but the problem did go away in later versions of Unity, so I figure there was a bug somewhere.
Your answer
![](https://koobas.hobune.stream/wayback/20220613141431im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Asset Bundles with In-App Payment in Unity Mobile 1 Answer
Animator in assetbundle from iphone app not play 1 Answer
Using AssetBundles as IAP Crashing 0 Answers
Does Apple allow you to download assetbundles with scriptableobjects, from an external server? 0 Answers
Accessing external asset bundles from local iOS files. 1 Answer