A method of recovering areas JVM

Many people think that in the method area (permanent or on behalf of the HotSpot virtual machine) is no garbage collection, Java Virtual Machine Specification did say that may not require a virtual machine approach to achieve garbage collection and garbage in the method area recycling "price" is usually relatively low because the area is generally what method do not need recovery, so scan it again rarely recovered.

Permanent generational garbage collection is divided into two parts: the time constant and useless waste of classes, and the constant recycling of waste recovered particular Java objects in the heap Similarly, i.e. when the method is to not referenced by any constant String object if the time garbage collection occurs, and if necessary, GC will recover the lost memory. It is determined whether a class is "useless class" stringent conditions will more:

1, all the strength of this class have been recovered, which is the Java heap any instance of the class does not exist.

2, the class loading ClassLoader has been recovered.

3, corresponding to the class java.lang.Class object is not referenced anywhere, not reflected by the method of accessing the class anywhere.

Virtual machine may be recovered useless class satisfies the above three conditions, it does not mean necessarily recovered.

Guess you like

Origin blog.csdn.net/qq_39429962/article/details/84879899