...
When an application goes through several phases such as an initialization and a ready phase, it could require heap compaction between phases. Given an uneventful period, System.gc()
may be invoked in such cases, provided that there is a suitable uneventful period between phases.
System.gc()
may be invoked as a last resort in a catch
block that is attempting to recover from an OutOfMemoryError
.
Related Vulnerabilities
The Apache Geronimo and Tomcat vulnerability GERONIMO-4574, reported in March 2009, resulted from PolicyContext handler data objects being set in a thread and never released. This caused these data objects to remain in memory longer than necessary.
...