Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Size of native memory in Android Profiler

In Android Studio Profiler, there are two places which display the size of native memory occupied by an app.

enter image description here

The first place is in the horizontal bar. Profiler documentation describes this as: "Native: Memory from objects allocated from C or C++ code".

The second place is the app heap dump, Native Size column. In documentation it is described: "Native Size: Total amount of native memory used by this object type (in bytes)"

In my case, the horizontal bar displays 30.12 MB and the heap dump "native size" column displays around 9.28 MB (which is the sum of all objects in app heap that have non-zero native size column)

Why are these two sizes different?

like image 203
camcam Avatar asked Feb 19 '18 09:02

camcam


People also ask

What is Android heap size?

Most devices running Android 2.3 or later will return this size as 24MB or higher but is limited to 36 MB (depending on the specific device configuration). If your app hits this heap limit and tries to allocate more memory, it will receive an OutOfMemoryError and will terminate. Heap memory is used to allocate objects.

What is native heap in Android?

The native heap is managed by dlmalloc() , which uses a combination of mmap() and standard calls like sbrk() to allocate memory. The managed ("Dalvik") heap is (mostly) one large chunk allocated with mmap() .

How do I check RAM usage on Android?

Tap Developer options and then tap Memory. In the resulting screen (Figure B), you'll see a list of the average memory used by the device in the past three hours (you can adjust the time frame, by tapping the time drop-down at the top). The Memory usage window in Android 12.


1 Answers

For the "horizontal bar" if you look closely you'll realize that the size of the memory used by graphics is 0. reason for this is that on some devices, bitmaps and other graphical assets are handled in the native memory. So extra memory other than the 9.28mb is most likely these graphical assets.

like image 57
thatGuy Avatar answered Oct 21 '22 12:10

thatGuy