Question about dvm heap(external and gc heap)

300 views
Skip to first unread message

Neo

unread,
Apr 19, 2011, 9:17:15 AM4/19/11
to android-platform
I found that Bitmap object is located in external heap area.
External heap area is not Garbage collected.
And external heap and gc heap are sharing dvm heap area.

Is there any reason to divide dvm heap into external heap and gc heap?
Is it for efficient?? What's the reason??

I thinak that the only usage of external heap is for Bitmap(Graphic,
skia, etc,,)
and Bitmap pixel data can be stored in GC Heap area.
and also can be accessed by jni native api, and protect from gc.


1. external heap
Bitmap object can be instanciate like this..
Bitmap b = Bitmap.createBitmap(src, 0, 0, width, height, m, filter);

and createBitmap method use JNI native method.
public static Bitmap createBitmap(int width, int height, Config
config) {
Bitmap bm = nativeCreate(null, 0, width, width, height,
config.nativeInt, true);
return bm;
}

and nativeCreate allocate memory in external memory area.
Bitmap_creator -> GraphicsJNI::setJavaPixelRef ->
bool r = env->CallBooleanMethod(gVMRuntime_singleton,
gVMRuntime_trackExternalAllocationMethodID, jsize);

2. gc heap
dvmAllocObject();

Neo

unread,
Apr 19, 2011, 10:19:24 AM4/19/11
to android-platform
In addition to above question,
Maximum dvm heap size limits external heap and gc heap.
Because of external heap plus gc heap can't exceed dvm max heap size.
Is there any reason to limit external heap size? (about Bitmap object)

When we use a user defined JNI native method.
and JNI native method use a native heap using malloc().
In this case, native heap usage is not tracked by dvm.
These means native heap usage could exceed dvm max heap size.

If the android want to limit the total dvm heap size.
then they have to track all usage of malloc in the JNI native call
stack.
But, now they are only tracking graphic JNI native api for Bitmap
object.

Romain Guy

unread,
Apr 19, 2011, 1:57:00 PM4/19/11
to android-...@googlegroups.com

As of Honeycomb bitamps are allocated on the DVM heap.

> --
> 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.
>
Reply all
Reply to author
Forward
0 new messages