Reputation: 191
I have an application that is communicating with an arduino and it runs a netty instance for controlling the arduino. The problem is I am not running out of memory but total heap size to used heap size is too low according to the adb logcat I am always around %10 free so any request to the netty server triggers a gc at which time I get a bunch of,
D/dalvikvm( 2862): WAIT_FOR_CONCURRENT_GC blocked 189ms
even simple requests that does not do anything (at least by me) loses atleast a second on gc pauses. I have
android:largeHeap="true"
set in my manifest and the simulator device has VM Heap of 512 mb but it is not allocating anywhere near that number (It is allocating around 10MB). I do not have a memory leak because 10% free is stable it goes +/- 2-3%. Even on a phone with 2 gigs of ram (with all other applications closed) I am always running with less then 2 3 MB of free heap is there a workaround for this?
Upvotes: 0
Views: 956
Reputation: 82543
The size of the device RAM doesn't really matter, as having a 2 GB RAM doesn't mean you'll get a 2GB heap.
The minimum heap size specified by Google in their recommendations is 16MB. You will not get a smaller heap than that.
largeHeap
only works on Android 3.0 and above, and it doesn't guarantee a bigger heap size.
There isn't much you can do to get a bigger heap, but you can rewrite your app using the NDK, in which heap size doesn't matter because you run outside the dalvik VM, and can hence use (almost) all of the device's RAM if need be.
However, running with 10% free of heap space isn't bad.
Upvotes: 1