We have developed NDK prototypes for a simple project. The code is compiled and working on device and in simulator. However when looking in the settings menu on the phones: (Samsung Galaxy Nexus(Android 4.2.2), Samsung Gio(Android 2.3.6)), running the app on the Gio takes a lot more space than when the app is run on the Galaxy Nexus. Also, the following command reports much higher heap allocations for the GIO:
System.out.println(Debug.getNativeHeapAllocatedSize() / 1049L);
We are using a static library for a lot of the functionality. The exact results are:
NEXUS:
GIO:
What is the reason for this difference in Footprint and memory usage?
(Measuring the allocations on an iOS device (C++ lib) yields approximately the same result on a 3GS as on a Galaxy Nexus).
There are lots of differences between Android 2.x and Android 4. An example is how bitmap memory is managed:
On Android Android 2.2 (API level 8) and lower, when garbage collection occurs, your app's threads get stopped. This causes a lag that can degrade performance. Android 2.3 adds concurrent garbage collection, which means that the memory is reclaimed soon after a bitmap is no longer referenced.
On Android 2.3.3 (API level 10) and lower, the backing pixel data for a bitmap is stored in native memory. It is separate from the bitmap itself, which is stored in the Dalvik heap. The pixel data in native memory is not released in a predictable manner, potentially causing an application to briefly exceed its memory limits and crash. As of Android 3.0 (API Level 11), the pixel data is stored on the Dalvik heap along with the associated bitmap.
Quoted from: http://developer.android.com/training/displaying-bitmaps/manage-memory.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With