Dalvik heap size limit

2,651 views
Skip to first unread message

Matt Shin

unread,
Dec 8, 2010, 3:36:40 AM12/8/10
to android-platform
Hi,
I'd like talk about the heap size limit by dalvik.vm.heapsize system
property.
basically it is a absolute max value related to out-of-mem exception
if an application request more than that.
the question here is why do we set small value like 16 or 24MB ? what
happens if we simply increase to 64MB?
As Dalvik has it's internal soft limit that leads to GC, there is no
waste of heap memory!
Of course there could be an application that utilizes 'soft reference'
as much as Dalvik permits.
But as far as i know, that case is negligible and it is better to
avoid application crash by OOM exception.
What do you think about this?

Jean-Baptiste Queru

unread,
Dec 8, 2010, 11:17:11 AM12/8/10
to android-...@googlegroups.com
That would cause different devices to behave differently for the same
app, which is not desirable if there are no other differences between
those devices that would cause apps to need different amounts of
memory.

JBQ

> --
> You received this message because you are subscribed to the Google Groups "android-platform" group.
> To post to this group, send email to android-...@googlegroups.com.
> To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.
>
>

--
Jean-Baptiste M. "JBQ" Queru
Software Engineer, Android Open-Source Project, Google.

Questions sent directly to me that have no reason for being private
will likely get ignored or forwarded to a public forum with no further
warning.

Romain Guy

unread,
Dec 8, 2010, 12:29:11 PM12/8/10
to android-...@googlegroups.com
Increasing the maximum heap size would also increase garbage collection times and you would have fewer apps resident in memory at the same time, thus making app switching potentially slower.
Romain Guy
Android framework engineer
roma...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support.  All such questions should be posted on public forums, where I and others can see and answer them

Matt Shin

unread,
Dec 10, 2010, 12:15:43 AM12/10/10
to android-platform
hmm.. I don't quite understand why garbage collection times increase.
Normal GC not claiming soft references will be done even before
reaching the maximum heap size.
As I mentioned before, the target heap or ideal heap size will be used
to determine when to do GC.
and the last time GC (before OOM crash) claims soft references, but
this behavior doesn't seem to increase GC times.
Would you please let me know a bit more details?
Thanks!

On 12월9일, 오전2시29분, Romain Guy <romain...@android.com> wrote:
> Increasing the maximum heap size would also increase garbage collection
> times and you would have fewer apps resident in memory at the same time,
> thus making app switching potentially slower.
>
>
>
>
>
>
>
>
>
> On Wed, Dec 8, 2010 at 8:17 AM, Jean-Baptiste Queru <j...@android.com> wrote:
> > That would cause different devices to behave differently for the same
> > app, which is not desirable if there are no other differences between
> > those devices that would cause apps to need different amounts of
> > memory.
>
> > JBQ
>
> > On Wed, Dec 8, 2010 at 12:36 AM, Matt Shin <matt.s...@gmail.com> wrote:
> > > Hi,
> > > I'd like talk about the heap size limit by dalvik.vm.heapsize system
> > > property.
> > > basically it is a absolute max value related to out-of-mem exception
> > > if an application request more than that.
> > > the question here is why do we set small value like 16 or 24MB ? what
> > > happens if we simply increase to 64MB?
> > > As Dalvik has it's internal soft limit that leads to GC, there is no
> > > waste of heap memory!
> > > Of course there could be an application that utilizes 'soft reference'
> > > as much as Dalvik permits.
> > > But as far as i know, that case is negligible and it is better to
> > > avoid application crash by OOM exception.
> > > What do you think about this?
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > "android-platform" group.
> > > To post to this group, send email to android-...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > android-platfo...@googlegroups.com<android-platform%2Bunsubscrib e...@googlegroups.com>
> > .
> > > For more options, visit this group at
> >http://groups.google.com/group/android-platform?hl=en.
>
> > --
> > Jean-Baptiste M. "JBQ" Queru
> > Software Engineer, Android Open-Source Project, Google.
>
> > Questions sent directly to me that have no reason for being private
> > will likely get ignored or forwarded to a public forum with no further
> > warning.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "android-platform" group.
> > To post to this group, send email to android-...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > android-platfo...@googlegroups.com<android-platform%2Bunsubscrib e...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/android-platform?hl=en.
>
> --
> Romain Guy
> Android framework engineer
> romain...@android.com

Matt Shin

unread,
Dec 10, 2010, 12:19:12 AM12/10/10
to android-platform
If different heap sizes cause different behaviors, what about
increasing the default value?
> > For more options, visit this group athttp://groups.google.com/group/android-platform?hl=en.

fadden

unread,
Dec 10, 2010, 3:35:43 PM12/10/10
to android-platform
On Dec 9, 9:15 pm, Matt Shin <matt.s...@gmail.com> wrote:
> hmm.. I don't quite understand why garbage collection times increase.

The point of having a larger heap is to have more stuff in memory. If
you have 2x as many objects, it takes 2x as long to scan them. (It's
not quite that simple, but you get the idea.)

Matt Shin

unread,
Dec 13, 2010, 4:50:07 AM12/13/10
to android-platform
thanks, Fadden.
I thought it was about how many times GC is performed regardless of
total amount of time spent. :)
And i absolutely agree that it is not that simple in terms of
efficiency and/or performance.

Anyway, my point was...
are there any possibilities that larger maximum heap configuration
will take more heap memory?
For instance, the calculator application is a very small application
which consumes much lesser heap than the maximum.
In other words, it never reach the maximum heap whatever we do !
In this case, increasing maximum heap limit will also increase the
amount of memory taken by the calculator application?
Thanks in advance for your time.

-- Matt

Dianne Hackborn

unread,
Dec 13, 2010, 1:02:32 PM12/13/10
to android-...@googlegroups.com
On Mon, Dec 13, 2010 at 1:50 AM, Matt Shin <matt...@gmail.com> wrote:
In this case, increasing maximum heap limit will also increase the
amount of memory taken by the calculator application?

No it won't.  The max heap size is already well above the amount Calculator needs, and Calculator doesn't grow to that size because it doesn't need it.

--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

James

unread,
Dec 13, 2010, 9:33:25 PM12/13/10
to android-platform
Long time no see :-)

On Dec 8, 11:17 am, Jean-Baptiste Queru <j...@android.com> wrote:
> That would cause different devices to behave differently for the same
> app, which is not desirable if there are no other differences between
> those devices that would cause apps to need different amounts of
> memory.
>
> JBQ
>
>
>
> - Hide quoted text -
>
> - Show quoted text -
>
>
>
> On Wed, Dec 8, 2010 at 12:36 AM, Matt Shin <matt.s...@gmail.com> wrote:
> > Hi,
> > I'd like talk about the heap size limit by dalvik.vm.heapsize system
> > property.
> > basically it is a absolute max value related to out-of-mem exception
> > if an application request more than that.
> > the question here is why do we set small value like 16 or 24MB ? what
> > happens if we simply increase to 64MB?
> > As Dalvik has it's internal soft limit that leads to GC, there is no
> > waste of heap memory!
> > Of course there could be an application that utilizes 'soft reference'
> > as much as Dalvik permits.
> > But as far as i know, that case is negligible and it is better to
> > avoid application crash by OOM exception.
> > What do you think about this?
>
> > --
> > You received this message because you are subscribed to the Google Groups "android-platform" group.
> > To post to this group, send email to android-...@googlegroups.com.
> > To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/android-platform?hl=en.
Reply all
Reply to author
Forward
0 new messages