Type-Based Amortised Heap-Space Analysis

  • Martin Hofmann
  • Steffen Jost
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3924)


We present a type system for a compile-time analysis of heap-space requirements of Java style object-oriented programs with explicit deallocation.

Our system is based on an amortised complexity analysis: the data is arbitrarily assigned a potential related to its size and layout; allocations must be “payed for” from this potential. The potential of each input then furnishes an upper bound on the heap space usage for the computation on this input.

We successfully treat inheritance, downcast, update and aliasing. Example applications for the analysis include destination-passing style and doubly-linked lists.

Type inference is explicitly not included; the contribution lies in the system itself and the nontrivial soundness theorem. This extended abstract elides most technical lemmas and proofs, even nontrivial ones, due to space limitations. A full version is available at the authors’ web pages.


Access Path Typing Judgement Subtyping Relation Class Table Object Creation 
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.
    Berger, E.D., Zorn, B.G., McKinley, K.S.: Reconsidering custom memory allocation. In: Proceedings of the Conference on Object-Oriented Programming: Systems, Languages, and Applications, OOPSLA (2002)Google Scholar
  2. 2.
    Bozga, M., Iosif, R., Laknech, Y.: Storeless semantics and alias logic. In: Proceedings of the 2003 ACM SIGPLAN workshop on Partial evaluation and semanticsbased program manipulation (PEPM), pp. 55–65. ACM, New York (2003)CrossRefGoogle Scholar
  3. 3.
    Chin, W.-N., Nguyen, H.H., Qin, S.C., Rinard, M.: Memory usage verification for OO programs. In: Hankin, C., Siveroni, I. (eds.) SAS 2005. LNCS, vol. 3672, pp. 70–86. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  4. 4.
    Deutsch, A.: Interprocedural may-alias analysis for pointers: beyond k-limiting. ACM SIGPLAN Notices 29(6), 230–241 (1994)CrossRefGoogle Scholar
  5. 5.
    Flatt, M., Krishnamurthi, S., Felleisen, M.: Classes and mixins. In: Proceedings of the 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), pp. 171–183 (1998)Google Scholar
  6. 6.
    Galland, A., Baudet, M.: Controlling and Optimizing the Usage of One Resource. In: Ohori, A. (ed.) APLAS 2003. LNCS, vol. 2895, pp. 195–211. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  7. 7.
    Gömez, G., Liu, Y.A.: Automatic time-bound analysis for a higher-order language. In: Proceedings of the 2002 ACM SIGPLAN workshop on Partial evaluation and semantics-based program manipulation, pp. 75–86. ACM Press, New York (2002)CrossRefGoogle Scholar
  8. 8.
    Grobauer, B.: Topics in Semantics-based Program Manipulation. PhD thesis, BRICS Aarhus (2001)Google Scholar
  9. 9.
    Hofmann, M., Jost, S.: Static prediction of heap space usage for first-order functional programs. In: Proceedings of the 30th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), pp. 185–197. ACM, New York (2003)CrossRefGoogle Scholar
  10. 10.
    Hughes, J., Pareto, L.: Recursion and dynamic data structures in bounded space: towards embedded ML programming. In: Proc. International Conference on Functional Programming (ICFP), Paris, September 1999, pp. 70–81 (1999)Google Scholar
  11. 11.
    Igarashi, A., Pierce, B., Wadler, P.: Featherweight Java: A minimal core calculus for Java and GJ. In: Meissner, L. (ed.) Proceedings of the 1999 ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages & Applications (OOPSLA), New York, vol. 34(10), pp. 132–146 (1999)Google Scholar
  12. 12.
    Ishtiaq, S.S., O’Hearn, P.W.: BI as an assertion language for mutable data structures. In: Proceedings of the 28th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), pp. 14–26. ACM, New York (2001)CrossRefGoogle Scholar
  13. 13.
    Jonkers, H.: Abstract storage structures. In: de Bakker, J.W., van Vliet, J.C. (eds.) Algorithmic Languages, pp. 321–343. IFIP, North Holland (1981)Google Scholar
  14. 14.
    Krone, J., Ogden, W.F., Sitaraman, M.: Modular verification of performance constraints. Technical report, Dep. of Comp. Sci., Clemson University (May 2003)Google Scholar
  15. 15.
    Rinetzky, N., Bauer, J., Reps, T., Sagiv, M., Wilhelm, R.: A semantics for procedure local heaps and its abstractions. In: Proceedings of the 32nd ACM SIGPLANSIGACT Symposium on Principles of Programming Languages (POPL), pp. 296–309. ACM Press, New York (2005)Google Scholar
  16. 16.
    Talpin, J.-P., Jouvelot, P.: Polymorphic type, region and effect inference. J. Funct. Program. 2(3), 245–271 (1992)MathSciNetCrossRefMATHGoogle Scholar
  17. 17.
    Tarjan, R.E.: Amortized computational complexity. SIAM Journal on Algebraic and Discrete Methods 6(2), 306–318 (1985)MathSciNetCrossRefMATHGoogle Scholar
  18. 18.
    Tofte, M., Birkedal, L., Elsman, M., Hallenberg, N., Olesen, T., Sestoft, P.: Programming with regions in the ml kit. IT University of Copenhagen (April 2002),
  19. 19.
    Tofte, M., Talpin, J.-P.: Region-based memory management. Information and Computation 132(2), 109–176 (1997)MathSciNetCrossRefMATHGoogle Scholar
  20. 20.
    Unnikrishnan, L., Stoller, S.D., Liu, Y.A.: Automatic accurate live memory analysis for garbage-collected languages. In: Proceedings of The Workshop on Languages, Compilers, and Tools for Embedded Systems (LCTES), ACM, New York (2001)Google Scholar
  21. 21.
    Vasconcelos, P.: Space Cost Modeling for Concurrent Resource Sensitive Systems. PhD thesis, School of Comp. Sci., University of St Andrews, Scotland (to appear)Google Scholar
  22. 22.
    Walker, D.W., Morrisett, G.: Alias types for recursive data structures. In: Harper, R. (ed.) TIC 2000. LNCS, vol. 2071, p. 177. Springer, Heidelberg (2001)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Martin Hofmann
    • 1
  • Steffen Jost
    • 2
  1. 1.Institut für InformatikLMU MünchenGermany
  2. 2.School of Computer ScienceUniversity of St AndrewsUK

Personalised recommendations