Good text recommended:
1. graphical Java garbage collection mechanism, very well done!
2. Become an expert Java GC (1): layman Java garbage collection
3. Become an expert Java GC (2): How to monitor Java garbage collection
4. Java GC to become experts (3): how to optimize Java garbage collection
5.java garbage collection algorithm
With the following questions to learn :( garbage collection garbage collector)
1. What is garbage collection? What is the automatic garbage collection?
2. java garbage collection algorithm
3. What needs to recover memory? --who
4. When the recovery? --when
5. how recycling? --how
6. gc how to reduce overhead optimization.
7.JVM memory partitioning (Memory Management)
How 8.jvm configuration parameters of gc
9. The basic process used in garbage collection mechanism / process. (How recycling)
(1) mark - Clear - Compression
eg: The first step: mark
. (The first step is to mark the garbage collector garbage collector at this time will find out which memory is in use (the program has a pointer to), what is not (has not been any pointers to point to) .)
Step two: Clear and compression
. (Clear refers to delete unreferenced objects marked out)
after (compression means in order to enhance performance, delete the unreferenced objects, you can also rest of the referenced objects together (compression), so that we can more quickly and easily assign a new object.)
(2) replication algorithm
The memory is divided into two, each with only one. When this piece of memory is full, the copy will also live objects to another piece, and in strict accordance with the arrangement of the memory address, and then the piece of used memory uniform recycling.
Advantage: the ability to obtain a continuous memory space
disadvantages are: waste half the memory
(3) generational algorithm
In java, the objects in memory according to the length of life is divided into:
- New Generation: survive for very long on the go die, such as local variables
- Years old: old fool, but it can also live for a long time go die, such as some of the long life cycle of an object
- Permanent Generation: Millennium bastard turtle years, immortality, such as load class information
There is one caveat: the old and the new generation's memory heap in java virtual machine; permanently stored on behalf of the district method
Supplementary Keywords:
Memory management awareness program run up on a steady diet of memory resource leak resource release
Automatic garbage collection memory allocation and management of reachability analysis
.