On Fri, Feb 25, 2011 at 8:31 AM, spaceraiders <spaceraid...@gmail.com>wrote:

> 1. Why was the decision made to not enforce the same limitations on
> NDK code?
>

It is much harder to enforce on native code.


> 2. What are the implications of rewriting apps that use the NDK to
> allocate, say, double the regular Java heap limit? I've done some
> experiments and e.g. using 40Mb on a phone with 256Mb RAM and a Java
> heap limit of 24Mb doesn't seem to cause any noticeable problems.
> Background apps start getting killed when you use a lot more memory
> though.
>

If you aren't careful in native code, your app will simply be silently
killed on you.


> 3. Are there any plans to increase the Java heap limit? Seeing as
> phones are now getting >=512Mb RAM, giving less than 10% of this to
> the foreground app seems an odd limitation.
>

The heap size is larger in HC.


> I've noticed apps on the market that say they require 256Mb RAM to run
> (!) so other developers are definitely taking advantage of the NDK in
> this way. I much prefer coding in Java but the memory limit makes
> certain apps very tough to write so sticking to Java makes it hard to
> compete with developers that use the NDK.
>

It's up to you whether you want to stay within the limit or risk issues like
your app suddenly disappearing on the user.

You can use the onLowMemory() callback to help you determine when you are
starting to allocate too much memory.  The browser uses this for example to
know when it really needs to flush its caches.  HOWEVER, you should NOT be
relying on that as the only way to control your allocations, since it
happens when the device is really getting low on memory to the point of not
being able to keep any background processes running, so things like app
switching are already being impacted by your memory use.

-- 
Dianne Hackborn
Android framework engineer
hack...@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.

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

Reply via email to