- Home /
Puzzle: Why game app on Android takes up much more memory than Unity Profiler reports?
We are profiling our game app on Android 4.4.2 device via Unity’s ADB profiling.
We have set up ADB profiling following the official guide: http://docs.unity3d.com/Manual/Profiler.html
The ADB profiling works fine, when the app is running, Unity Profiler reports its memory usage as following:
Used Total: 100.4 MB Unity: 40.5 MB Mono: 10.1 MB GfxDriver: 34.9 MB FMOD: 3.9 MB Profiler: 14.8 MB Reserved Total: 112.8MB Unity: 47.0 MB Mono: 15.4 MB GfxDriver: 34.9 MB Profiler: 15.5 MB
Meanwhile, we are also running another performance test tool (i.e. Emmagee, https://github.com/NetEase/Emmagee) to monitor the app, which can monitor CPU, memory, network traffic, battery current and etc. However, the memory usage of the app reported by Emmagee tool is much larger:
As shown above, Unity Profiler reported 112.8M memory is totally reserved for running the app, but Emmagee tool reported >200M PSS memory is used. Obviously, more than 90M memory taking up is happened somewhere by something that Unity Profiler does not take into account.
(We also tried other performance monitoring tool for Android apps, e.g. APT, and the result is similar to what Emmagee reported. The extra memory usage problem remains.)
We noticed that the Unity Profiler itself would take up ~15M memory, which is included in the profiler’s report. Also, we knew that PSS memory includes proportional shared libraries with other processes, but 90M+ extra is such large amount considering that Unity Profiler only reported 112.8M totally.
Our puzzle remained: Where does the 90M+ memory come from? How are they used by the app? Why Unity Profiler does not report the extra memory? What can we do for reducing the extra memory and the total PSS memory of the running app, and/or get it close to what Unity Profiler reports?
Any help could be appreciated!
Also the same... It drives me mad about the lack of information..
Hi! Any positive news on that? I seem to have a similar issue but on iOS: https://forum.unity3d.com/threads/5-4-1-unitys-profiler-device-memory-consumption-differs-from-xcode-numbers.434871/
BTW, what version of Unity do you use?
Answer by tarasfromlviv · Oct 30, 2015 at 01:36 PM
The thing most likely is that Unity Profiler Profiles only things that are actually your game related (your sandboxed game info) and external tools show you everything including all the Unity player consumes at total. If the Unity profiler showed you everything unrelated to your game and engine internals there would have been a lot of noise in the profiler. So the profile shows you the memory you have the direct influence on withing your project.
The thing is you shouldn't worry about the things you cannot change, maximum you can do is to be careful withing what you are doing within the app.
Answer by NewbilityShanghai · Nov 02, 2015 at 02:46 PM
With further research, I can give a guess. Here is my test:
Test my game with a totally empty scene when start, memory cost is 68.3MB.(Notice, the scene is totally empty, no assets is loaded)
I try to remove a lot prefabs in my game, generate the apk file, run the game start with the empty scene again, the memory cost is 38.46MB.
I try to add some of the prefabs back to my game and run the game again and again, I noticed that when I add very complicated prefabs back, the memory cost will be tremendous.
Here's my guess:
Unity will preLoad the "prefab structure" into memory on android, this is why you will need extra memory even the prefab is never clone in current scene. Only the structure but not the assets such as texture will be "Preloaded".
The way to solve the problem:
I tried to remove all the complicated prefabs, instead to create new scene and make new gameobjects in the scene, the memory cost appears reasonable.
The problem appears when we use large and complicated prefabs to construct the level design, and load it when the scene is started. Also, the theory is only my guess, I look forward to someone can explain this more "Officially" or something.
Your answer
Follow this Question
Related Questions
Puzzle: Why game app on Android takes up much more memory than Unity Profiler reports? 0 Answers
Certificate problems when installing APK file on Android phone from command line 1 Answer
Error trying to build for android. 2 Answers
Why does the internal profiler show no GPU usage? 1 Answer
Android profiling, fps, vsync 1 Answer