So my question is similar to this: Android: how to increase heap size at runtime?
However, since I'm not dealing with caching, the answer provided about a better caching implementation does not apply to me. My goal is allocate a large heap as a temporary solution to my timing issue that I believe GC_CONCURRENT is affecting and my goal is to allocate a heap such that GC_CONCURRENT doesn't happen. I would like to emphasize I do not have a memory leak as when GC_CONCURRENT runs it always frees up 15% and that number does not go down and I've since optimized my code such that I have no variable initializations in any loops and things are declared static and final where possible.
I've tried setting android:largeHeap="true"
but it has had no visible effect so I'm looking for something that isn't a polite request to the OS and does effectively the same thing as the depreciated VMRuntime.getRuntime().setMinimumHeapSize(BIGGER_SIZE)
I'm looking for something that isn't a polite request to the OS and does effectively the same thing as the depreciated VMRuntime.getRuntime().setMinimumHeapSize(BIGGER_SIZE)
There is no means to do this in the Android SDK. Otherwise, every developer would think that they are a special snowflake and deserve 16GB of system RAM on a 512MB device.
I've tried setting android:largeHeap="true" but it has had no visible effect
You can use getMemoryClass()
and getLargeMemoryClass()
(on ActivityManager
) to see what the difference is in your heap limit when using android:largeHeap="true"
. Also, bear in mind that android:largeHeap="true"
is only available on API Level 11+ devices.
I've since optimized my code such that I have no variable initializations in any loops and things are declared static and final where possible.
You are certainly welcome to use the DDMS Allocation Tracker, heap dumps, and the like to determine the source of your memory usage that is triggering the GC.