long max = codeCacheMbean.getUsage().getMax();
if (used > 0.7 * max) {
// Due to some obscure bug in hotspot (java 7), once the code cache fills up the JIT stops compiling and never recovers from this condition.
// By forcing classes to unload from the perm gen, we let the code cache evictor make room before the cache fills up.
// For best results, the server should be run with -XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent -XX:+CMSClassUnloadingEnabled
log.info("Triggering GC to avoid Code Cache eviction bugs");
System.gc();
}
else if (used > 0.95 * max) {
log.error("Code Cache is more than 95% full. JIT may stop working.");
}