Automatic Removal of Array Memory Leaks in Java

Current garbage collection (GC) techniques do not (and in general cannot) collect all the garbage that a program produces. This may lead to a performance slowdown and to programs running out of memory space. In this paper, we present a practical algorithm for statically detecting memory leaks occurring in arrays of objects in a garbage collected environment. No previous algorithm exists. The algorithm is conservative, i.e., it never detects a leak on a piece of memory that is subsequently used by the program, although it may fail to identify some leaks. The presence of the detected leaks is exposed to the garbage collector, thus allowing GC to collect more storage. We have instrumented the Java virtual machine to measure the effect of memory leaks in arrays. Our initial experiments indicate that this problem occurs in many Java applications. Our measurements of heap size show improvement on some example programs.

[1]  William Pugh,et al.  The Omega test: A fast and practical integer programming algorithm for dependence analysis , 1991, Proceedings of the 1991 ACM/IEEE Conference on Supercomputing (Supercomputing '91).

[2]  BlanchetBruno Escape analysis for object-oriented languages , 1999 .

[3]  Vivek Sarkar,et al.  Enabling Sparse Constant Propagation of Array Elements via Array SSA Form , 1998, SAS.

[4]  Geoff W. Hamilton,et al.  Compile-Time Garbage Collection for Lazy Functional Languages , 1995, IWMM.

[5]  Patrick Cousot,et al.  Systematic design of program analysis frameworks , 1979, POPL.

[6]  Thomas W. Reps,et al.  Precise interprocedural dataflow analysis via graph reachability , 1995, POPL '95.

[7]  Amer Diwan,et al.  Compiler support for garbage collection in a statically typed language , 1992, PLDI '92.

[8]  Steven S. Muchnick,et al.  Advanced Compiler Design and Implementation , 1997 .

[9]  Stephen N. Freund,et al.  Adding type parameterization to the Java language , 1997, OOPSLA '97.

[10]  Martin C. Rinard,et al.  Compositional pointer and escape analysis for Java programs , 1999, OOPSLA '99.

[11]  Andrew C. Myers,et al.  Parameterized types for Java , 1997, POPL '97.

[12]  Zoran Budimlic,et al.  Optimizing Java: theory and practice , 1997, Concurr. Pract. Exp..

[13]  Benjamin Goldberg,et al.  Escape analysis on lists , 1992, PLDI '92.

[14]  Barbara Liskov,et al.  A history of CLU , 1993, HOPL-II.

[15]  Paul R. Wilson,et al.  Uniprocessor Garbage Collection Techniques , 1992, IWMM.

[16]  Craig Schaffert,et al.  CLU Reference Manual , 1984, Lecture Notes in Computer Science.

[17]  David Detlefs,et al.  Garbage collection and local variable type-precision and liveness in Java virtual machines , 1998, PLDI.

[18]  Samuel P. Midkiff,et al.  Optimizing Array Reference Checking in Java Programs , 1998, IBM Syst. J..

[19]  Jong-Deok Choi,et al.  Efficient and precise modeling of exceptions for the analysis of Java programs , 1999, PASTE '99.

[20]  Martin Odersky,et al.  Making the future safe for the past: adding genericity to the Java programming language , 1998, OOPSLA '98.

[21]  Michael Wolfe,et al.  High performance compilers for parallel computing , 1995 .

[22]  Ronald L. Rivest,et al.  Introduction to Algorithms , 1990 .

[23]  Bruno Blanchet,et al.  Escape analysis: correctness proof, implementation and experimental results , 1998, POPL '98.

[24]  Michael Wolfe,et al.  Elimination of redundant array subscript range checks , 1995, PLDI '95.

[25]  Eugene W. Myers,et al.  A precise inter-procedural data flow algorithm , 1981, POPL '81.

[26]  Mads Tofte,et al.  Implementation of the typed call-by-value λ-calculus using a stack of regions , 1994, POPL '94.

[27]  Nicolas Halbwachs,et al.  Automatic discovery of linear restraints among variables of a program , 1978, POPL.

[28]  Bruno Blanchet,et al.  Escape analysis for object-oriented languages: application to Java , 1999, OOPSLA '99.

[29]  Richard Jones,et al.  Garbage collection , 1996 .

[30]  Hans-Juergen Boehm,et al.  Garbage collection in an uncooperative environment , 1988, Softw. Pract. Exp..

[31]  Rajiv Gupta,et al.  Optimizing array bound checks using flow analysis , 1993, LOPL.

[32]  Vivek Sarkar,et al.  Array SSA form and its use in parallelization , 1998, POPL '98.

[33]  P. Gács,et al.  Algorithms , 1992 .

[34]  Robert Cartwright,et al.  Compatible genericity with run-time types for the Java programming language , 1998, OOPSLA '98.

[35]  Rafael Dueire Lins,et al.  Garbage collection: algorithms for automatic dynamic memory management , 1996 .

[36]  Edsger W. Dijkstra,et al.  A Discipline of Programming , 1976 .

[37]  Lars Birkedal,et al.  From region inference to von Neumann machines via region representation inference , 1996, POPL '96.

[38]  Cyrille Comar,et al.  Targeting GNAT to the Java virtual machine , 1997, TRI-Ada '97.