Cork: Dynamic Memory Leak Detection for Java
Maria Jump, Kathryn S. McKinley · 2006
Despite all the benefits of garbage collection, memory leaks remain a problem for Java programs. A memory leak in Java occurs when a program inadvertently maintains references to objects that it no longer needs, preventing the garbage collector from reclaiming space. At best, leaks degrade performance. At worst, they cause programs to run out of memory and crash. Small continuous leaks in long-running programs are notoriously hard to find and can crash the program only after days or weeks of execution. We introduce Cork, a low-overhead, accurate technique for detecting memory leaks in Java programs. Cork identifies overa ll monotonic heap growth by piggybacking on the garbage collector. On each full-heap collection, Cork builds a summary type pointsto graph annotated with type volumes. Cork identifies potentia lly leaking types that grow over multiple collections. Cork reports the slice in the type points-to graph that is growing (i.e., the data st ructure that points to the leaking type). We implement Cork in MMTk for Jikes RVM, where it adds an average overhead of 2.4% for moderate heap sizes and 1.7% for large heap sizes to SPECjvm and DaCapo benchmarks using a generational mark-sweep collector. Cork exactly identifies a single growing data structure in ea ch of three popular benchmarks (fop, 202 jess, and SPECjbb2000). Due to the precision of Cork’s report, we eliminated these le aks in 202 jess and SPECjbb2000, whereas their developers had not previously done so. Cork is the first tool to find leaks in Java w ith low enough overhead to consider using online.