Profiling Object Life Ranges for Detecting Memory Leaks in Java Virtual Machine
Qingyue Sun, Xiaohua Shi, Junru Xie · 2012
Java Virtual Machine (JVM) has its garbage collector (GC) to manage all the java objects and the heap memory. However, in many Java applications, some Java objects will not be visited by the programs, but could not be automatically reclaimed by the garbage collector. These Java objects would cause the memory leaks. Obtaining the life ranges of all Java objects in the heap memory could help programmers to find the kind of memory leaks. This paper presents two approaches to scan the garbage-collector-managed heap memory to record the living status of all Java object at runtime. One approach is called All-Scanning mechanism, and the other is called Incremental-Scanning mechanism. The All-Scanning mechanism scans heap objects after GC reclaiming the objects in a static way. The Incremental-Scanning mechanism could incrementally collect the status of heap objects when GC reclaims the objects. We use SpecJVM98 and SpecJBB2000 to evaluate the runtime performance and analyze the profiling results for both mechanisms. The profiling results of the two mechanisms are consistent, while the Incremental-Scanning mechanism is at least 1.82 times faster than the All-Scanning one on average. From the profiling results, we could figure out the life cycles of every object, the movements of the object allocations, and the potentially leaked objects. We also use three workloads, namely List Leak, Swap Leak and MySql, to demonstrate how to find out the leaked objects from the profiling results.