18_ class namespace and unloading Detailed and use jvisualvm

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_43277087/article/details/102720793

Here Insert Picture Description
Class unloading

Here Insert Picture Description

Here Insert Picture Description
Here Insert Picture Description

Here Insert Picture Description
The resulting output is:
Here Insert Picture Description

How to see the original class loader and loaded class has not been unloaded?
Here Insert Picture Description
After the operation, the result did not change
Expository not unloaded
so, explicitly calling gc

Here Insert Picture Description
The output is:
Here Insert Picture Description
class is unloaded
if the three reference not set to null?
Here Insert Picture Description
Operational results are:
Here Insert Picture Description
not unloaded
because when you call gc when the reference is still pointing to the original object
after the call, only to point to the new object, the gc does not make sense
, then, the gc another location

Here Insert Picture Description

Here Insert Picture Description
In this case, the class is unloaded

Use the tool to see jvisualvm

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/qq_43277087/article/details/102720793