Hi ! I have been working on a project and getting some memory issues on low end devices (512 MB).
I compared the profiler stats for iOS and windows phone 8 and identified that WP8 is using almost 30 MB extra memory. I have compressed all my textures to DXT5. My unity version is 5.1.3f1
Here are the profiler stats of iOS and WP8 for the same game state.
Hi,
what kind of texture format are you using on iOS?
are you using any kind of plugins on Windows Phone?
are you targeting windows phone 8.0 or 8.1?
could you make a screenshot of Unity profiler memory on iOS (similar to what you made on Windows Phone)?
We are using uncompressed/16 bits texture format on iOS.
Yes we are using some plugins for windows phone.
I am currently targeting Windows Phone 8.0 (not WSA).
Here is the Unity’s iOS profiler screenshot
Apparently something is allocating memory which does not get picked up by Unity profiler. Unfortunately, it is very much dependent on your application. You could use Visual Studio Memory profiler to track all allocations and find out exactly what’s eating your memory.
I’ve been able to replicate this with an empty project as well. For Windows Phone builds, the discrepancy is around 30 mbs, but for Windows Store Universal 8.1, it jumps up to 200mb in the profiler. Repro project is attached. Just create Windows Phone 8 and Windows Store Universal 8.1 development builds and run. I’m using Unity 5.1.3f1
Here is the link to the bug report :
https://fogbugz.unity3d.com/default.asp?733871_hc1pc9u8699hkpgm
2327204–157083–WP8MemoryTest.rar (14.8 KB)
Any updates on this issue? I’m having the same problem, even with 5.2.1.
We don’t have any updates yet, but generally a lesser or bigger discrepancy between what Unity shows and Windows thinks that the application is using is expected. There are couple of things that Unity profiler does not track:
- JITed code size.
- Graphics driver internal allocations (this tend to be pretty big on desktop, not so much on phones).
- Memory used by loaded modules.
- Any memory allocated by plugins.
Without profiling specific project, I can only guess what’s taking space.
Well, even running an empty project shows massive memory usage (around 60 MB), so I can rule out any external code. This is on a Nokia Lumia 720. Running it on a Lumia 925 bumps that up to 85 MB. We have a large number of our users affected by this, and we need to resubmit our game ASAP, so I would appreciate any insight into this. Strangely, Visual Studio profiling shows heap size as 20.7MB only, so I have around 65MB of memory unaccounted for (maybe GFX allocations?). I’ll play around with the settings some more and update.
Update: The performance settings were set to Fantastic by default. Setting them to Fastest lowered the memory usage on the Nokia Lumia 925 to 55 MB, which is definitely better but still too high given nothing is being rendered at all.
Update 2: Running an empty project built by Unity 4.6.8 reduces memory usage in the 925 to 30MB. Quality settings are still fastest.
Windows is one of our largest platforms, and a large number of our users are affected by this. Can you please give any insight, because I am at a dead end. Even the Visual Studio profiler shows nothing: heap size is around 50MB, but application shows 100MB memory used. In one case, Unity reports 90MB total memory used, but total system memory is 180MB, which leads to instant crashes on 512MB devices.
Are you targeting Windows Phone 8.0 or 8.1? When profiling in visual studio, select “native” memory profiler, and after capturing the snapshot, you should be able to see a tree-graph that shows what allocated that memory.
Right now, we’re targeting Windows Phone 8.0. For Windows Phone 8 builds, using the performance analysis tool, heap size is around 6MB, but total memory used is ~100 MB. I’ll create a build targeting Windows 8.1 and check native heap size and update this post.
Visual Studio Profiler:
Unity Profiler for same scene:
For the Windows Phone 8.1 builds, the situation is more or less the same. Native Heap size is ~27MB, Managed Heap Size is ~4MB, but total memory usage is ~100MB.
Native Heap:
Managed Heap:
Unity:
By clicking on those allocations in VS you show be able to get a summary of what allocated that memory.
You’re using 120 MB total in your game: since 180 MB is the limit, are you sure you’re running into that issue? You’ve got a lot of headroom at least according to the info you provided.
The scene I’ve taken the profiler samples from is just a basic loading scene, with a few assets preloaded. When the game loads, the memory shoots up to 190MB:
The allocation calls are from UnityPlayer.dll, and profiler shows them as unknown frames:
Even if I could tell what these allocations are, they only account for 45MB of allocated memory. Add in the native heap, which was ~13MB, and there still is a lot of memory allocated in the private set unaccounted for. The Unity profiler for the same scene (which crashes on 512 MB devices):
What’s bugging me is the discrepancy between the used total and system memory usage: it is almost 100MB, so more than half the available memory for 512MB apps is unaccounted for. If you run the empty project attached above, it shows similar discrepancies (55MB private set), even though heap size is ~20MB.
It does look weird. Unity thinks it’s using 120 MB, while the OS thinks it uses 208 MB. I’m not exactly sure why Visual Studio profiler is displaying nonsense.
I know one more tool that should be more accurate than both visual studio and unity profilers: Windows Performance Analyzer. You can record performance trace using Field Medic App:
https://mmaitre314.github.io/2014/12/01/field-medic-custom-logging.html
Use the memory profile:
http://mmaitre314.github.io/download/MultimediaMem.wprp
After recording a trace, crack it open in Windows Performance analyzer and see what’s allocating memory:
It should give you the exact numbers what and where allocates memory.
WPA Traces:
Nokia Lumia 720 (512 MB):
Nokia Lumia 925 (1 GB):
The game crashes on the 720, since it’s reached the 180 MB mark. The main discrepancy between the two devices seems to be the much higher allocations (35 MB diff) by UnityPlayer.dll!UnityPlayer::AppCallbacks::ExecuteQueuedCallbacks on the 720. Any insight on this?
Also, on both devices the, UnityPlayer.dll!GfxDeviceD3D11Base::UploadTexture2D allocations amount to ~70 MB. This seems strange to me, as the Unity Profiler shows max texture allocations to 58MB.
Hope this sheds some light on my issue. I can also send you both traces if that helps.
Could you expand that column? AppCallbacks::ExecuteQueuedCallbacks is a generic loop that executes callbacks that have been queued up on our main thread, so it’s not giving us too much info.
Regarding texture size and Unity profiler: our profiler approximates the memory used based on texture size, but it cannot be exact what kind of additional allocations graphics driver will make. Basically, Unity profiler is guessing and displaying the used memory too low.
Expanded as much as I could:
It’s hard to analyze it using just these images. Could you zip up the .etl files together with UnityPlayer.pdb, Assembly-CSharp.pdb, etc that match the build you profiled, upload it somewhere and then PM me the link?
PM’ed you the link, thanks.