Liveness-Based Garbage Collection

  • Rahul Asati
  • Amitabha Sanyal
  • Amey Karkare
  • Alan Mycroft
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8409)


Current garbage collectors leave much heap-allocated data uncollected because they preserve data reachable from a root set. However, only live data—a subset of reachable data—need be preserved.

Using a first-order functional language we formulate a context-sensitive liveness analysis for structured data and prove it correct. We then use a 0-CFA-like conservative approximation to annotate each allocation and function-call program point with a finite-state automaton—which the garbage collector inspects to curtail reachability during marking. As a result, fewer objects are marked (albeit with a more expensive marker) and then preserved (e.g. by a copy phase).

Experiments confirm the expected performance benefits—increase in garbage reclaimed and a consequent decrease in the number of collections, a decrease in the memory size required to run programs, and reduced overall garbage collection time for a majority of programs.


Garbage Collection Forward Path Program Point Access Path Garbage Collector 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 1.
    Röjemo, N., Runciman, C.: Lag, drag, void and use—heap profiling and space-efficient compilation revisited. In: ICFP (1996)Google Scholar
  2. 2.
    Karkare, A., Sanyal, A., Khedker, U.: Effectiveness of garbage collection in MIT/GNU Scheme (2006),
  3. 3.
    Shaham, R., Kolodner, E.K., Sagiv, M.: Estimating the impact of heap liveness information on space consumption in Java. In: ISMM (2002)Google Scholar
  4. 4.
    Chatterjee, R., Ryder, B.G., Landi, W.A.: Relevant context inference. In: POPL (1999)Google Scholar
  5. 5.
    Cherem, S., Rugina, R.: A practical escape and effect analysis for building lightweight method summaries. In: Krishnamurthi, S., Odersky, M. (eds.) CC 2007. LNCS, vol. 4420, pp. 172–186. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  6. 6.
    Lee, O., Yang, H., Yi, K.: Static insertion of safe and effective memory reuse commands into ML-like programs. Science of Computer Programming (2005)Google Scholar
  7. 7.
    Khedker, U.P., Sanyal, A., Karkare, A.: Heap reference analysis using access graphs. TOPLAS (2007)Google Scholar
  8. 8.
    Karkare, A., Khedker, U., Sanyal, A.: Liveness of heap data for functional programs. In: Heap Analysis and Verification Workshop, HAV (2007),
  9. 9.
    Chakravarty, M.M.T., Keller, G., Zadarnowski, P.: A functional perspective on SSA optimisation algorithms. In: COCV (2003)Google Scholar
  10. 10.
    Mohri, M., Nederhof, M.J.: Regular approximation of context-free grammars through transformation. In: Junqua, J.C., van Noord, G. (eds.) Robustness in Language and Speech Technology, pp. 251–261. Kluwer Academic Publishers (2000)Google Scholar
  11. 11.
    Hopcroft, J.E., Ullman, J.D.: Introduction to Automata Theory, Languages, and Computation. Addison-Wesley Longman Publishing Co., Inc., Boston (1990)Google Scholar
  12. 12.
    Jones, S.B., Metayer, D.L.: Compile-time garbage collection by sharing analysis. In: FPCA (1989)Google Scholar
  13. 13.
    Wadler, P.: Deforestation: Transforming programs to eliminate trees. In: Ganzinger, H. (ed.) ESOP 1988. LNCS, vol. 300, pp. 344–358. Springer, Heidelberg (1988)CrossRefGoogle Scholar
  14. 14.
    Gill, A., Launchbury, J., Jones, S.L.P.: A short cut to deforestation. In: FPCA (1993)Google Scholar
  15. 15.
    Chitil, O.: Type inference builds a short cut to deforestation. In: ICFP (1999)Google Scholar
  16. 16.
    Hofmann, M.: A type system for bounded space and functional in-place update. In: ESOP (2000)Google Scholar
  17. 17.
    Tofte, M., Birkedal, L.: A region inference algorithm. TOPLAS (1998)Google Scholar
  18. 18.
    Inoue, K., Seki, H., Yagi, H.: Analysis of functional programs to detect run-time garbage cells. TOPLAS (1988)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2014

Authors and Affiliations

  • Rahul Asati
    • 1
  • Amitabha Sanyal
    • 1
  • Amey Karkare
    • 2
  • Alan Mycroft
    • 3
  1. 1.IIT BombayMumbaiIndia
  2. 2.IIT KanpurKanpurIndia
  3. 3.Computer LaboratoryUniversity of CambridgeUK

Personalised recommendations