Increasing the memory heap to more than 16 Mb

928 views
Skip to first unread message

vishal bhoj

unread,
May 6, 2009, 9:06:31 AM5/6/09
to android-...@googlegroups.com, android-...@googlegroups.com
Hello All,

Why is the reason for limiting the memory heap to 16 MB. Is it possible to change the limitation of memory heap of application from 16M to 32 M. What would be the repercussion of increasing the Heap size. The requirement here is decoding of high resolution images which fails because of shortage of memory . How can this be done .

--
with regards vishal

Dan Bornstein

unread,
May 7, 2009, 8:33:18 PM5/7/09
to android-platform
On May 6, 6:06 am, vishal bhoj <vishalb...@gmail.com> wrote:
> Why is the reason for limiting the memory heap to 16 MB. Is it possible to
> change the limitation of memory heap of application from 16M to 32 M. What
> would be the repercussion of increasing the Heap size.

This is done, effectively as a platform configuration, as one of
several compromises in the platform aimed to allow for a reasonable
number of simultaneous processes to be active at any given time, given
the amount of system RAM typically available in an incarnation of the
platform.

As Magnus correctly indicated, this can be changed as part of platform
configuration. However, it can't be set on a per-app basis, since that
would inevitably lead to a kind of war of "required RAM escalation,"
ultimately ending up with many apps requesting RAM sizes that are
simply inappropriate for the device they are running on, leading to a
poor end-user experience.

This is similar to the cpu priority issue that was discussed a month
or so ago. In particular, the Android philosophy is to try to balance
capabilities provided to apps against end-user desires, where a
baseline desire is taken to be that the user wishes to have a device
that is responsive and doesn't crash. You might be able to argue for
an adjustment in policy details — e.g., maybe it should be 20 megs —
but I don't think you will make much headway arguing against the
philosophy.

And with respect to the details, over time, as Android-based devices
gain more RAM in their typical incarnations, you can expect this limit
to be raised in the default configuration of the platform.

If you have an application that requires more than 16 megs today, then
it probably isn't suitable for wide deployment to Android-based
devices in general, right now. However, if you are building your own
custom platform (e.g., deploying your app as part of a vertical
solution that also includes the entire OS), then you can of course
tweak the platform to your heart's content.

-dan

vishal bhoj

unread,
May 8, 2009, 5:17:09 AM5/8/09
to android-...@googlegroups.com

Dan,

My scenario is kind of the one described above.  We are trying to have a custom platform with limited application on android.

Can you describe where the allocation of heap takes place . I will start looking into vm/alloc/ ...
 

-dan





--
with regards vishal

fadden

unread,
May 8, 2009, 3:55:24 PM5/8/09
to android-platform
On May 8, 2:17 am, vishal bhoj <vishalb...@gmail.com> wrote:
> My scenario is kind of the one described above.  We are trying to have a
> custom platform with limited application on android.
>
> Can you describe where the allocation of heap takes place . I will start
> looking into vm/alloc/ ...

In frameworks/base/core/jni/AndroidRuntime.cpp:

#ifdef CUSTOM_RUNTIME_HEAP_MAX
#define __make_max_heap_opt(val) #val
#define _make_max_heap_opt(val) "-Xmx" __make_max_heap_opt(val)
opt.optionString = _make_max_heap_opt(CUSTOM_RUNTIME_HEAP_MAX);
#undef __make_max_heap_opt
#undef _make_max_heap_opt
#else
/* limit memory use to 16MB */
opt.optionString = "-Xmx16m";
#endif

So you can define a CUSTOM_RUNTIME_HEAP_MAX with some other value,
e.g. "32m" to double the existing limit.
Reply all
Reply to author
Forward
0 new messages