2
votes

Edit : Is this statement "So in android 2.3 concurrent mark and sweep is used for stack related objects treating everything as pointer and copying garbage collection is used for the objects in the heap" correct ? Any one can explain ? garbage collector in android 2.3

I know the subject of Garbage Collection in Android has been discussed, but I can't find a clear and detailed explanation of how it works and specially in the last version of Android which is Jelly Bean 4.2.

In addition to the main question I have two more specific questions :

1) Which algorithms (Mark and Sweep, Concurrent Mark and Sweep, Copying, generational, incremental..) are implemented and how have they been adapted to actual Android/Dalvik ?

2) As I am beginner, how can I by my self break down how it works (methodology or tools) ?

Any input is appreciated.

1

1 Answers

7
votes

Dalvik's garbage collector hasn't changed significantly since Gingerbread (2.3), so any information you can find of that era or newer will likely apply to Jellybean.

It uses a concurrent mark-and-sweep approach. It doesn't copy or compact, and has a slight notion of generations (optimizations for memory allocated by the zygote).

The best way to understand how it works is to read the sources. Most of the relevant code lives in dalvik/vm/alloc.