Course Content
Core Java
About Lesson

Heap space allocation: When the JVM needs to allocate memory for a new object, and there is not enough space in the heap, it triggers garbage collection to reclaim unused memory or store them in the survivor space.

System.gc() method call: You can explicitly request garbage collection by calling the System.gc() method, although there is no guarantee that it will run.

Old generation threshold: Garbage collection can also be triggered when the heap size of the old generation heap space (which stores long-lived objects) reaches a certain threshold.

PermGen/Metaspace threshold: In Java versions before Java 8, garbage collection can also be triggered when the size of the PermGen (Permanent Generation) or Metaspace (in Java 8 and later) memory areas reaches a certain threshold.

Time-based: Sometimes, garbage collection can be triggered based on a time interval. For example, the JVM might trigger garbage collection every hour or every day, regardless of memory usage.

Scroll to Top