Memory Usage Verification for OO Programs

  • Wei-Ngan Chin
  • Huu Hai Nguyen
  • Shengchao Qin
  • Martin Rinard
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3672)


We present a new type system for an object-oriented (OO) language that characterizes the sizes of data structures and the amount of heap memory required to successfully execute methods that operate on these data structures. Key components of this type system include type assertions that use symbolic Presburger arithmetic expressions to capture data structure sizes, the effect of methods on the data structures that they manipulate, and the amount of memory that methods allocate and deallocate. For each method, we conservatively capture the amount of memory required to execute the method as a function of the sizes of the method’s inputs. The safety guarantee is that the method will never attempt to use more memory than its type expressions specify. We have implemented a type checker to verify memory usages of OO programs. Our experience is that the type system can precisely and effectively capture memory bounds for a wide range of programs.


Memory Usage Type Rule Type Checker Type Judgement List Node 
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.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Aldrich, J., Kostadinov, V., Chambers, C.: Alias Annotation for Program Understanding. In: ACM OOPSLA, Seattle, Washington (November 2002)Google Scholar
  2. 2.
    Alpern, B., Attanasio, D., Barton, J.J., Cocchi, A., Hummel, S.F., Lieber, D., Mergen, M., Ngo, T., Shepherd, J., Smith, S.: Implementing Jalapeño in Java. In: ACM OOPSLA, Denver, Colorado (November 1999)Google Scholar
  3. 3.
    Aspinall, D., Compagnoni, A.: Heap bounded assembly language. Journal of Automated Reasoning 31, 261–302 (2003)zbMATHCrossRefGoogle Scholar
  4. 4.
    Berger, E.D., Zorn, B.G., Mckinley, K.S.: Reconsidering Custom Memory Allocation. In: ACM OOPSLA (November 2002)Google Scholar
  5. 5.
    Boyland, J., Noble, J., Retert, W.: Capabilities for sharing. In: Knudsen, J.L. (ed.) ECOOP 2001. LNCS, vol. 2072, p. 2. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  6. 6.
    Cachera, D., Jensen, T., Pichardie, D., Schneider, G.: Certified memory usage analysis. In: Fitzgerald, J.S., Hayes, I.J., Tarlecki, A. (eds.) FM 2005. LNCS, vol. 3582, pp. 91–106. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  7. 7.
    Carlisle, M.C., Rogers, A.: Software caching and computation migration in Olden. In: 4th Principles and Practice of Parallel Programming, Santa Barbara, California (May 1993)Google Scholar
  8. 8.
    Chan, E.C., Boyland, J., Scherlis, W.L.: Promises: Limited Specifications for Analysis and Manipulation. In: Proceedings of the International Conference on Software Engineering, Kyoto, Japan, April 1998, pp. 167–176 (1998)Google Scholar
  9. 9.
    Chin, W.N., Khoo, S.C., Qin, S.C., Popeea, C., Nguyen, H.H.: Verifying Safety Policies with Size Properties and Alias Controls. In: Inverardi, P., Jazayeri, M. (eds.) ICSE 2005. LNCS, vol. 4309, Springer, Heidelberg (2006)Google Scholar
  10. 10.
    Chin, W.N., Nguyen, H.H., Qin, S.C., Rinard, M.: Predictable Memory Usage for Object-Oriented Programs. Technical report, SoC, Natl Univ. of Singapore (November 2004), avail. at,
  11. 11.
    Christiansen, M.V., Velschow, P.: Region-Based Memory Management in Java. Master’s Thesis, Department of Computer Science (DIKU), University of Copenhagen (1998)Google Scholar
  12. 12.
    Fahndrich, M., Leino, R.: Declaring and checking non-null types in an object-oriented language. In: ACM OOPSLA, Anaheim, CA (October 2003)Google Scholar
  13. 13.
    Hoare, C.A.R., He, J.: Unifying Theories of Programming. Prentice-Hall, Englewood Cliffs (1998)Google Scholar
  14. 14.
    Hofmann, M., Jost, S.: Static prediction of heap space usage for first order functional programs. In: ACM POPL, New Orleans, Louisiana (January 2003)Google Scholar
  15. 15.
    Hughes, J., Pareto, L.: Recursion and Dynamic Data-Structures in Bounded Space: Towards Embedded ML Programming. In: Proceedings of the International Conference on Functional Programming (ICFP 1999) (September 1999)Google Scholar
  16. 16.
    IBM. JikesTM Research Virtual Machine (RVM),
  17. 17.
    Lamport, L.: The temporal logic of actions. ACM Trans. on Programming Languages and Systems 16(3), 872–923 (1994)CrossRefGoogle Scholar
  18. 18.
    Peyton-Jones, S., et al.: Glasgow Haskell Compiler,
  19. 19.
    Pugh, W.: The Omega Test: A fast practical integer programming algorithm for dependence analysis. Communications of the ACM 8, 102–114 (1992)CrossRefGoogle Scholar
  20. 20.
    Tofte, M., Talpin, J.: Region-based memory management. Information and Computation 132(2) (1997)Google Scholar
  21. 21.
    Xi, H., Pfenning, F.: Eliminating array bound checking through dependent types. In: ACM PLDI, June 1998. ACM Press, New York (1998)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2005

Authors and Affiliations

  • Wei-Ngan Chin
    • 1
    • 2
  • Huu Hai Nguyen
    • 1
  • Shengchao Qin
    • 3
  • Martin Rinard
    • 4
  1. 1.Computer Science ProgrammeSingapore-MIT Alliance 
  2. 2.Department of Computer ScienceNational University of Singapore 
  3. 3.Department of Computer ScienceUniversity of Durham 
  4. 4.Laboratory for Computer ScienceMassachusetts Institute of Technology 

Personalised recommendations