Monstruous Memory Usage

The snapshot of memory usage has been taken directly from the app running on a test device (iPhone). The total allocated memory seems to be 502.7MB, which coincides with the memory usage reported in Xcode.

I used the Memory Profiler package and took snapshots to break down the memory usage within the Unity project. The total memory used in the Unity project is 176MB. I optimized shaders, cut down on the use of materials, and optimized texture import settings, which are the top 3 memory-consuming areas. However, it seems there is little I can do apart from what I’ve done already to reduce the total memory usage of the app while running.

While 176MB of memory usage might seem a lot already for low-end mobile devices, it’s not as crazy as the 262.3MB used by the Native memory footprint, for which I don’t have much control over.

The project is simple (although it contains quite a few graphics assets): it only contains a single scene, with some panels and a few sprites, using Unity UI. It uses the AdMob SDK, which I think contributes to the Native memory footprint when converting to native C/C++ code. Also, I communicate with devices’s cloud and game services and native UI (alert dialogs). There’s nothing else apart from this. I would like to know a breakdown of the Native memory distribution to see which libraries or processes are taking/using the most memory, but it doesn’t seem I have access to it.

I don’t know if somebody has experience something similar and could provide insights into things could be done to improve it.

Thank you for reading.

Have you profiled a release build? Generally debug builds consume a lot more memory.

You could check how much AdMob uses by creating a new project and build once, then add Admob and build again and compare the memory usage. Just so you have an idea what portion of memory AdMob uses. There may be settings or usage recommendations for AdMob in their manual regarding optimizing memory usage.

1 Like

9737926--1392838--upload_2024-3-29_16-10-16.png

This is an empty project in Unity 2D. Xcode (above) already gives it a High Energy Impact tag, with 169.1MB of memory usage. Of course, the ‘object stats’ are using less than 1MB, so there’s no much one can do (after all it’s an empty project).


I added the AdMob SDK and it’s mostly the same: 170MB vs 175.5MB (with AdMob).

Finally, with the IAP module, Cloud & Game services, and Native UI (alert dialogs) enabled, it goes to 190+MB:
9737926--1392859--upload_2024-3-29_17-5-8.png

The project only consists of a single game object, which is the default camera, and these packages.

190MB seems a lot to me. Also, there’s a difference of 70MB between the 260MB I was seeing on the other project and the 190MB of this empty project that I can’t seem to track.

Again, is this a debug or release build? There could be worlds between the two.

High energy impact is normal for any game, due to updating the screen 60 times per second even if it only gets cleared.

Sorry, I forgot to reply. The data I’ve shown here is with a debug (Development Build + Autoconnect Profiler) because I wanted to be able to track down the memory usage.

However, I built the project with a release build before for testing in TestFlight and the memory usage was 475-480MB in Xcode, compared to the 500MB of the debug build, so there doesn’t seem to be much of a difference.

Actually, I was wrong. The data provided was on “Release”, if you meant the “Run in Xcode as” section:
9738367--1392979--upload_2024-3-29_22-33-3.png