G1 Full GC does not purge code root memory, and that causes a memory leak. The leak is illustrated in the attached file after_8141421_fix.png.
I made the following simple change that purges the code root memory
in the Full GC control path. With this change this leak goes away. (see attached file after_purge_fix.png)
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
+++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
@@ -1423,6 +1423,7 @@
hot_card_cache->reset_card_counts();
hot_card_cache->reset_hot_cache();
}
+ purge_code_root_memory();
// Rebuild remembered sets of all regions.
if (G1CollectedHeap::use_parallel_gc_threads()) {
We currently purge code root memory in VM_G1IncCollectionPause operation but not in VM_G1CollectFull which is causing this leak.