Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What mechanism causes classes to be unloaded by the JVM?

0
Posted

What mechanism causes classes to be unloaded by the JVM?

0

When a class is referenced (i.e. with a new statement) for the first time, the class definition is loaded using either the default class loader or a custom one if you’ve defined one. The class definition is stored in an area of the Java heap called the Perm Space. All allocated instances of that class definition have a reference back to the reference stored in the Perm Space. When there are no longer any class instances that reference that class definition, the definition becomes a candidate for collection. The next time a full garbage collection takes place, all class definitions in the Perm Space that aren’t referenced by any actual instances will be cleaned up or unloaded. One way to trigger a full garbage collection is if the Perm Space fills up. This can be seen by watching the output of -Xverbosegc and looking for the cause of GC.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123