How to correctly utilise AssetBundles - Massive memory usage, 4x more than Resource folder
I'm having a lot of trouble figuring out how I am meant to use asset bundles so they don't take gigabits of RAM. I am downloading my bundles with:
UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(url,version,0)
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request);
Then saving that bundle to a variable in a singleton for access during runtime: data_bundle = bundle;
Then, when I need the images for my cards in the bundle, I load them all into a dictionary from the bundle like so:
imageCache[imageName] = data_bundle .LoadAsset<Sprite>(imageName);
And then when a card needs an image take it from the imageCache.
This is obviously wrong, I did the same thing with the resource folder (Loading all images from resources to a cache which was used during runtime), and I am now using more than 4x the RAM. Why? - what is the correct method to use AssetBundles?
Answer by Mowtine · Nov 06, 2021 at 05:00 PM
This seemed to be caused by different import settings on my assets from my resources and the folder where the bundle was being made.
Your answer
![](https://koobas.hobune.stream/wayback/20220613045023im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Increase in build memory +2GB 0 Answers
Does empty array declaration take memory? 1 Answer
Need help with memory management 0 Answers
Terrain "Creating System" consuming infinite memory [Please Help] 0 Answers