- Home /
Why Unity has high memory usage on empty scene? (Android)
No matter what I do or have in a unity project it says over a 100 mb is being used at any given time. I load the apk onto a Note 8 device and the running processes says 185 mb is being used. I ran empty scene with debugging mode attached to an Note 8 as well and in the profile it said it was using 11.3 mb. This is make my head explode as I can't get any work done with such high memory usage on android. If you look at the screen shots there is no object in the scene, no assets in the Asset folder and yet the scene takes 110.1 MB with (it says) 8 game objects in scene when there is none. Once I start to populate the scene with a few objects it quickly goes to 150 MB or more. This is insane. The only memory profile I really care about is once the app is on a Android device but Android reports memory usage much higher that what is shown on the Unity profiler.
Does anyone know whats going on? Am I reading everything correct? Can you reproduce this on a empty scene with your version of Unity. By the way, I'm using Unity 2017.3.0f3.
Answer by pako · Jan 03, 2018 at 09:41 PM
I tried to replicate your setup/settings as much as possible, and I'm on Unity 2017.2.1 (new android project). See screenshots.
My figures are a bit lower, but not excessively lower e.g. total memory used 96MB vs 110MB, etc. Actually, total memory used started at about 90MB with default settings i.e. use VSync, Shading Mode "Shaded" instead of "Shaded Wireframe", Directional Light in the scene, and rendering skybox. Then I changed these settings to replicate your project and memory went to 96MB.
So, given the differences in our PCs, I think your setup reflects pretty much what we are all working with.
So where did the extra 6 $$anonymous$$B come from when disabling things? I though when things are disable or trashed, more memory should be free. I am trying to make a live wallpaper but I notice the limit for a scene in memory is between 0 - 180mb. Anything beyond this threshold, the phone or tablet starts to get very hot. I notice there are live wallpapers that only take up 70 - 130 $$anonymous$$B (looking at running processes on phone) while co$$anonymous$$g from Unity and I can't even get a scene with good amount of objects in it without it heating up the device. Any tips? And also when going from Unity to Android, there was a add 80-85 $$anonymous$$B. Where did it come from?
I understand why you want all these answers, but the thing is, do you really need all these answers to make your LWP as other Unity users have done so far? The problem is that most of what you want to know is undocumented, and require in-depth knowledge of all systems concerned i.e. Unity, Android, and specific devices as they mostly customize Android OS. Especially for the latter, and taking into consideration the immense diversification in Android devices, it's almost impossible to know all relevant -mostly undocumented- information.
So, the emphasis in my response was "I think your setup reflects pretty much what we are all working with".
I just started Unity with your repro project, and this time the Profiler showed total memory 86$$anonymous$$B, 10$$anonymous$$B less form last night... ...and that was with skybox, I then changed to solid colour and the memory went up by 2$$anonymous$$B to 88$$anonymous$$B :-) go figure!
also when going from Unity to Android, there was a add 80-85 $$anonymous$$B
I suspect that this is due to the difference between running something in the Editor and the Unity Android Player.
The bottom of the line is that you can create LWPs with Unity but Unity is targeted toward games and not LWPs. As a result, the Unity Android Player always has to load in order to play the LWP, and additionally, many libraries that are not needed for a LWP are also loaded up. All these add up, and some compromises have to be made, if you want to take advantage of the ease of working with Unity to create a LWP. However, if your LWP project can't "fit", then just make games with Unity ;-) which I$$anonymous$$HO would be much more worth your while.
I have quite an experience with Unity made LWP's, and I'm also the OP in this https://feedback.unity3d.com/suggestions/reinstate-support-for-android-live-wallpapers I've published 6 LWPs, both 2D and 3D (with intensive pathfinding), and lots and lots of HD textures. $$anonymous$$emory usage and overheating were never a problem!
Thanks for the advice! I just went on head with what I was trying to do and it turn out to be that I was running the unity LWP at native resolution on the note 8 device which is near 3k. So when I use the screen.currentResolution.width and height / 3, it reduce the memory usage by around 60-80 $$anonymous$$B and the render still looks good at a smaller resolution. At least for the what I am trying to accomplish, this suits well.
I'm actually making game as well along side with this project and amazingly learning a lot of things about Unity that I wouldn't have explored due to the limits of running on Android in which I will use to further optimize my game.