Because of the time problem, simply talk about your own understanding.
As we all know, in Android development, do not need to manage their own, a garbage collection mechanism will automatically help us to recycle
There are no objects that are referenced to.
What exactly is the garbage collection mechanism? Here is a list of some of my understanding.
Garbage-Collected Threads:
It was previously done in the main thread, and later moved to a lower priority.
Previously, a single thread followed by multithreading.
Time for garbage collection:
When the app is idle
When memory is tight
Allocating large chunks of memory is not enough time.
How to recycle:
Does not use generational technology: a one-time GC will traverse all objects, which can be time consuming
The use of generational technology: divided into young generation, the old age, lasting generations. This can put the short life cycle, large and small objects into the young generation
Once a GC can traverse only the younger generation, as long as the freed memory enough can not go through the old age and so on.
Recycling Start:
The garbage collection thread begins the traversal of the object reference from the root set.
The so-called "root Set" is a collection of reference variables that can be accessed in a running thread, such as arguments and local variables for the current function of all threads, member variables of the current class, and so on.
The garbage collection thread first finds all objects that are directly referenced by the root set (called Collection 1).
Then find all the objects that are directly referenced by the collection 1 (called Set 2),
Then find all objects that are directly referenced by Collection 2 ... This repeats itself until all the objects that can be traversed are traversed.
Any object that can be reached from the root set through the above traversal is called a reachable object or a valid object, and conversely, an unreachable object or a defunct object (that is, garbage).
Algorithm for recycling:
Reference count
Labeling method
Object Tree
Monitoring of recycling :
You can override the object Finalize () function. This function is called before the object is recycled.
More information can be found at the following address:
http://hulefei29.iteye.com/blog/658546
Small analysis of Android GC memory recycle