Memory Usage Optimization and Profiler

Hi !

My problem is simple (I think). When I build and play the game I’m working on, I see a RAM usage of nearly 2.2GB. But when I’m in editor and use the Profiler (with or without Deep Profile), it announces me a memory usage of 1.1GB.
Why this difference ? And what could I do to minimize the RAM usage ?

Thanks !

Do you unload any assets that aren’t currently being used? Do you have way too many things loaded at once? Could you use more culling? Graphics optimization? General optimization? Texture compressions?

Seems to me that’s not a problem with the build, but rather a problem that the Profiler does not register the total amount of used memory (correctly).

For example, I just tried that allocating several 100 MB worth of float arrays in both Editor or build make the process grow exactly the expected size. However, the Profiler stays constantly at 51MB and does not grow at all. So maybe it collects data only from Unity objects, or Unity serialized objects, or something like that. Although, the docs do claim "Note that in the Unity Editor this is memory used by everything in the editor; game builds will use much less."

Can you estimate the amount of memory your data should consume? What kind of data is it, Unity objects, standard C# objects, Terrain data, …?

When starting from a freshly starting editor and running your app that supposedly uses 1.1GB, what’s the process size of the Editor? It should be somewhere around 2.4-2.5GB (2.2GB “true” process size plus Editor overhead).

If this is correct, 2.2GB is the true memory usage of your process, then the Profiler is wrong/incomplete.

One thing you could do to check/optimize the amount of data integrated into your build (i.e., disk space, as opposed/only remotely related to execution size) is to check the Editor log right after a build. Somewhere near the end you will find a long, size-sorted list of Assets that were integrated in your build. Check the sizes+names of the largest ones.