Heap profiling for space-efficient Java

We present a heap-profiling tool for exploring the potential for space savings in Java programs. The output of the tool is used to direct rewriting of application source code in a way that allows more timely garbage collection (GC) of objects, thus saving space. The rewriting can also avoid allocating some objects that are never used. The tool measures the difference between the actual collection time and the potential earliest collection time of objects for a Java application. This time difference indicates potential savings. Then the tool sorts the allocation sites in the application source code according to the accumulated potential space saving for the objects allocated at the sites. A programmer can investigate the source code surrounding the sites with the highest savings to find opportunities for code rewriting that could save space. Our experience shows that in many cases simple code rewriting leads to actual space savings and in some cases also to improvements in program runtime. Experimental results using the tool and manually rewriting code show average space savings of 18% for the SPECjvm98 benchmark suite. Results for other benchmarks are also promising. We have also classified the program transformations that we have used and argue that in many cases improvements can be achieved by an optimizing compiler.

[1]  Gary Sevitsky,et al.  Visualizing reference patterns for solving memory leaks in Java , 1999, Concurr. Pract. Exp..

[2]  Niklas Röjemo,et al.  Lag, drag, void and use—heap profiling and space-efficient compilation revisited , 1996, ICFP '96.

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

[4]  Jeffrey M. Barth Shifting garbage collection overhead to compile time , 1977, CACM.

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

[6]  Elliot K. Kolodner,et al.  Automatic Removal of Array Memory Leaks in Java , 2000, CC.

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

[8]  Torben Æ. Mogensen,et al.  A Backwards Analysis for Compile-time Garbage Collection , 1990, ESOP.

[9]  Alain Deutsch,et al.  Semantic models and abstract interpretation techniques for inductive data structures and pointers , 1995, PEPM '95.

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

[11]  Michael Hind,et al.  Which pointer analysis should I use? , 2000, ISSTA '00.

[12]  Thomas W. Reps,et al.  Precise Interprocedural Dataflow Analysis with Applications to Constant Propagation , 1995, TAPSOFT.

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

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

[15]  Elliot K. Kolodner,et al.  On effectiveness of GC in Java , 2000, ISMM '00.

[16]  Bilha Mendelson,et al.  Sharpening global static analysis to cope with Java , 1998, CASCON.

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

[18]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[19]  Bernhard Steffen,et al.  Optimal code motion: theory and practice , 1994, TOPL.

[20]  Rajiv Gupta,et al.  A practical framework for demand-driven interprocedural data flow analysis , 1997, TOPL.

[21]  Hans-Juergen Boehm,et al.  Understanding memory allocation of scheme programs , 2000, ICFP '00.

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