changing the heap limit on apps

by devi prasad » Sun, 29 Mar 2009 16:57:10 GMT

Sponsored Links
Can someone point me to the code that enforces the 16MB heap limit?
If we want to increase the allowed heap size to say 24MB, what
additional care should we take so we do not violate other guarantees
already enforced in the system?




changing the heap limit on apps

by devi prasad » Sun, 29 Mar 2009 18:26:44 GMT

 well, looking around I found the following in dalvik/vm/init.c:

/* Defaults overridden by -Xms and -Xmx.
 * TODO: base these on a system or application-specific default
gDvm.heapSizeStart = 2 * 1024 * 1024;   // Spec says 16MB; too big for us.
gDvm.heapSizeMax = 16 * 1024 * 1024;    // Spec says 75% physical mem;

I notice that gDvm.heapSizeMax gets passed (directly or indirectly) to
the rest of the vm code.
Also, are the comments mentioned in the code true? Can we avoid the
default limit by passing larger values to the said arguments?




Sponsored Links

changing the heap limit on apps

by fadden » Mon, 30 Mar 2009 19:43:04 GMT


You can, if you can pass the arguments.  The VM is embedded in the
Android runtime, not launched on the command line.

What you're really looking for is in frameworks/base/core/jni/
AndroidRuntime.cpp; search for CUSTOM_RUNTIME_HEAP_MAX to see where
somebody else has already done an override at compile time.  Note the
heap max is passed in through "-Xmx".

The part where this gets tricky is that the VM is only initialized
once; all subsequent instances of the VM are the result of a fork()
with no exec().  Once the VM has been initialized you can't change the
heap max, because some data structures are sized to match.  Giving one
app a larger virtual heap is most easily accomplished by giving
everybody a larger heap and then forcing most of them to make do with
less than the actual maximum.  The less-easy but better approach would
be to resize the various heap structures, which is a bit awkward but
probably doable since there's only thread running at that point where
the zygote forks.

You can also fork+exec the new process, but now you're losing the size
and startup time advantages that the zygote provides.



changing the heap limit on apps

by devi prasad » Tue, 31 Mar 2009 05:06:32 GMT

 Hi fadden: thanks a lot. This is useful. This is interesting too!



Other Threads

1. Mainan bar

Oh AgMon... eh salah yah yang dimaksud @ts

Minggat \()/

"Indonesian Android Community [id-android]"

PING'S mobile
Email:  Ph. (021) 96087100
Yopie Ratjoen
Email:  Ph. 08977726681
Gila original
Email:  Ph. (031) 91555898

Aturan Jual/Kloteran ID-Android

2. More complex Scrollview example needed.

       Hello there,
I am working on some sort of record lookup for a database. My code
allows to search for some kind of string within an index (of that
database) and returns the database-position of the found thing . With
this found position my programm is then able to move to adjacent
records from the database moving forward and backwards from the
initial position in small steps.

ListView seems to not work in this case, as ListView starts per
default at ListAdapter position 0 and not at an arbitrary position in
the (here virtual) list. The api-docs doesnt seem to specify some sort
of "start somewhere else and follow during scrolling". At least I
haven't found that.

So what I thought of is to use a ScrollView. Unfortunately I don't
have a real understanding of how that could be realized with a huge
number of records (and not just a handfull like in the examples).

So, my questions are:
- Is it possible to start a ListView at some defined position (without
reimplementing {Abs}ListView)
- Or can someone provide an example on how to implement a more complex



3. omap3evm rev-D froyo dsp version Android desktop not launching

4. Fwd: to use only a single frame layout for oading different-2 images from drawable folder

5. Cronos Froyo Milestone Update 1.4

6. Video is not shown when returning to app

7. How to upgrade Eclair (2.0) to Froyo (2.2)