Android native heap memory limit

1,397 views
Skip to first unread message

vardan.p...@picsart.com

unread,
Aug 25, 2016, 9:59:17 AM8/25/16
to android-ndk
 Hi,
 What is the maximal available memory for native heap?
 On android 4.4.2 I was able to allocate up to 1.2GB memory (in the native heap) but same code crashes on android 5, so what has been changed in android os's native heap management?  

NoAngel

unread,
Sep 5, 2016, 11:16:17 AM9/5/16
to android-ndk
AFAIK, there is no easy way to check exact free memory size. Also it's not constant, it changes very often. Better solution is to use virtual memory as swap file. This file can be created somewhere on storage and mmapped, so You will have know max size block of memory. Then start using it, used pages will be cached in RAM as possible, but if there is not enough RAM they will be unloaded from memory and saved to storage.
Depends on memory block size u need u may create it every time app launches, and delete when not needed, or, if it's small enough just create it once and use.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages