0

I did a test on Android 4.4 Kit Kat where i allocated 100MB, and checked the process memory via adb shell dumpsys meminfo -d and saw the Dalvik Heap breakdown: Heap Size and Heap Alloc increased.

I also checked system memory via adb shell cat /proc/meminfo and saw how much free memory it has.

Then i released the memory (and even called System.gc() after).

I then checked the process memory again and saw that in Dalvik Heap breakdown Heap Size remains the same, Heap Alloc decreased and Heap Free increased!

I also run adb shell cat /proc/meminfo and saw that the system didn't reclaim any memory! I don't understand what's going on.

When i did the same test on Android 7.1 and Android 5.0, the memory was reclaimed upon releasing it!

darkThoughts
  • 403
  • 6
  • 18
  • See: [How do I discover memory usage of my application in Android?](https://stackoverflow.com/q/2298208/295004) which discusses behavior in older devices (check timestamps) before ART which became the default in Android 5.0. – Morrison Chang Jan 24 '19 at 21:01
  • @MorrisonChang i read that already and if you see in my question i used the same commands to verify my claim. – darkThoughts Jan 26 '19 at 23:17
  • Unless you reference specific sources, I can't tell what you read. If you are just trying to understand how Android handles memory, beyond the external links in the post I referenced, I hope that [Garbage Collector not freeing “thrash memory” as it should in an Android application](https://stackoverflow.com/q/52177254/295004) is similar enough to answer your question, or give enough context to improve your question, especially how you are allocating and calling garbage collection. – Morrison Chang Jan 27 '19 at 06:28
  • Additional there are videos covering how Android deals with memory from the Google I/O conference: [Understanding Android memory usage (Google I/O '18)](https://youtu.be/w7K0jio8afM) and [Performance and Memory Improvements in Android Run Time (ART) (Google I/O '17)](https://youtu.be/iFE2Utbv1Oo), which may be useful. Videos going back to the earliest conference are online should you wish to learn what was disseminated to app developers for earlier versions of the platform. – Morrison Chang Jan 27 '19 at 06:48

0 Answers0