Addressable System does not release memory after assets completely released

Hello,
I’ve been tasked with improving memory usage and it seems that Addressable Asset System is the best for the purpose. I came up with a simple Android app to get familiar with Addressable and to see how it effects memory. Inside the app, I will load a sequence of assets (sprite atlases, sizes vary from 1MB to 16MB) and then release them (in reversed order). There are 11 loads and 11 releases. At each load/release, I check Android Studio’s Memory Profiler and record memory usage into a spreadsheet for comparison.

What I naively expected to see in Memory Profiler

  • When an atlas is loaded, the memory would increase the exact amount as the atlas size
  • When an atlas is released, the memory would decrease the same amount

The first thing I noted in Memory Profiler was that Graphics memory was the only that varied during loading/releasing which made perfect sense (Java and Code memory did vary but in a random way, so I think they can be ignored)

I have tested with 8 devices and the results are interesting

  • Group 1 (Oppo, Vsmart, Samsung, Huawei, LG): the memory changes seem intuitively, it increase with load, and decrease with release. But the amount of increase/decrease is not always the same as the size of the atlas being loaded/released
  • Group 2 (Xiaomi Note 5, Xiaomi Note 7 and Google Pixel 4XL): memory increases to its peak after a few loads, and remain unchanged for subsequent loads/release

(You can see this in the attached file)

And this held true for all devices: memory after releasing all atlases is bigger than the memory at start (no atlas loaded), it’s about 32M more (total atlases are 70MB)

So here are the questions :

  • Does Addressable not work in Group 2, since memory never gets released ?
  • Why is memory after all atlases released even bigger than when start ?
  • Why does memory behave so differently between those groups ?

Any help would be appreciated !

I would check memory usage with Memory Profiler package or built-in in Unity Profiler memory module.
From the screenshots I can see that Group2 (mostly) has memory usage <75MB. This could be the case of memory pools fragmentation which settle game memory usage to the certain amount of allocated memory.

Unity allocates memory from a system in larger chunks (1-4-16MB) and releases it in chunks too. If a chunk has an active allocation from some system or any persistent asset, it stays in memory - it is technically a memory reservation Unity uses for later loads.

My feeling is that the picture your see on different devices is a combination of texture format and the pool memory system Unity uses - more likely on some phones the textures are unpacked causing higher memory mark and then released settling the memory usage at pools reservation level 75-100MB. However LG phone stands out with 35MB…

For future people I’ll post this:

  • check your AddressableGroupSettings.BundleMode should be ‘Pack Separately’, to unload AssetBundles independently from each other
2 Likes