Below is a code snippet that one can use to get the heap size and the used memory size.
#if UNITY_IPHONE && !UNITY_EDITOR
[DllImport("__Internal")]
#else
[DllImport("mono")]
#endif
static extern long mono_gc_get_used_size(); //Amount Used
#if UNITY_IPHONE && !UNITY_EDITOR
[DllImport("__Internal")]
#else
[DllImport("mono")]
#endif
static extern long mono_gc_get_heap_size(); //Total Amount
long memUsed = mono_gc_get_used_size();
long deltaMem = memUsed - previousMemUsed;
long heapSize = mono_gc_get_heap_size();
float percentageMemUsed = (memUsed / (float)heapSize)
* 100;
previousMemUsed = memUsed;
For more profiling, use these tools: http://docs.unity3d.com/Documentation/Manual/Profiler.html
No comments:
Post a Comment