Android DALVIKVM Memory Management Understanding

Source: Internet
Author: User

Many files on the Web introduce the theory of JVM memory management, but how to implement it in DALVIKVM.

These days have looked at the source code of DALVIKVM, say my understanding:


At a large level, like theory, the JVM divides the memory into areas




For a description of each district, see.

http://blog.csdn.net/lengyuhong/article/details/5953544


For a simple program like Hello World, it is found that DALVIKVM also uses a heap, which is the Eden area.


DALVIKVM uses MMAP to create shared memory (heaps are shared by multiple threads), which is the Eden area, which is then managed by itself (mspace_free,mspace_calloc, etc.) in dlmalloc (and not in memory allocations that call the OS, This may be because performance can be predicted.)

Code in: Dalvik/vm/alloc/heapsource.cpp#dvmheapsourcestartup

It should be noted that in addition to using DLMALLOC,DALVIKVM or 2 bitmap to correspond to the entire heap, a call Livebitmap, a markbitmap is to do GC.

1 in the GC process, the first to clear the Markbitmap 0

2 in the Sweepscan process, find each object pointer, in the corresponding Markbitmap position, which is a depth-first (using the stack) search algorithm

3 in Livebitmap, but Markbitmap objects that are not marked are those that are released with Mspace_free when sweep.

4markbitmap became a livebitmap show that live objects

Go to the next cycle


Because the object is big and small, and bitmap is to map a bit according to the smallest size of object, there must be a wasted space, but it is worthwhile to waste it for the sake of real marksweep efficiency.


New Object


(Note: The general new Creation object is implemented in multiple assemblies, but also called to Dvmallocobject)


Garbage collection sequence diagram







Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.