skip to main content
article

Reconsidering custom memory allocation

Published:04 November 2002Publication History
Skip Abstract Section

Abstract

Programmers hoping to achieve performance improvements often use custom memory allocators. This in-depth study examines eight applications that use custom allocators. Surprisingly, for six of these applications, a state-of-the-art general-purpose allocator (the Lea allocator) performs as well as or better than the custom allocators. The two exceptions use regions, which deliver higher performance (improvements of up to 44%). Regions also reduce programmer burden and eliminate a source of memory leaks. However, we show that the inability of programmers to free individual objects within regions can lead to a substantial increase in memory consumption. Worse, this limitation precludes the use of regions for common programming idioms, reducing their usefulness.We present a generalization of general-purpose and region-based allocators that we call reaps. Reaps are a combination of regions and heaps, providing a full range of region semantics with the addition of individual object deletion. We show that our implementation of reaps provides high performance, outperforming other allocators with region-like semantics. We then use a case study to demonstrate the space advantages and software engineering benefits of reaps in practice. Our results indicate that programmers needing fast regions should use reaps, and that most programmers considering custom allocators should instead use the Lea allocator.

References

  1. Apache Foundation. Apache Web server. http://www.apache.org.Google ScholarGoogle Scholar
  2. William S. Beebee and Martin C. Rinard. An implementation of scoped memory for Real-Time Java. In EMSOFT, pages 289--305, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Emery D. Berger, Kathryn S. McKinley, Robert D. Blumofe, and Paul R. Wilson. Hoard: A scalable memory allocator for multithreaded applications. In International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS-IX), pages 117--128, Cambridge, MA, November 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Emery D. Berger, Benjamin G. Zorn, and Kathryn S. McKinley. Composing high-performance memory allocators. In Proceedings of the 2001 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 114--124, Snowbird, Utah, June 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Greg Bollella, James Gosling, Benjamin Brosgol, Peter Dibble, Steve Furr, and Mark Turnbull. The Real-Time Specification for Java. Addison-Wesley, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Gilad Bracha and William Cook. Mixin-based inheritance. In Norman Meyrowitz, editor, Proceedings of the Conference on Object-Oriented Programming: Systems, Languages, and Applications (OOPSLA) / Proceedings of the European Conference on Object-Oriented Programming (ECOOP), pages 303--311, Ottawa, Canada, 1990. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Dov Bulka and David Mayhew. Efficient C++. Addison-Wesley, 2001.Google ScholarGoogle Scholar
  8. Trishul Chilimbi. Efficient representations and abstractions for quantifying and exploiting data reference locality. In Proceedings of the 2001 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 191--202, Snowbird, Utah, June 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Trishul M. Chilimbi, Mark D. Hill, and James R. Larus. Cache-conscious structure layout. In Proceedings of the 1999 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 1--12, Atlanta, GA, May 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Margaret A. Ellis and Bjarne Stroustrop. The Annotated C++ Reference Manual. Addison-Wesley, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Boris Fomitchev. STLport. http://www.stlport.org/.Google ScholarGoogle Scholar
  12. Christopher W. Fraser and David R. Hanson. A Retargetable C Compiler: Design and Implementation. Addison-Wesley, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Free Software Foundation. GCC Home Page. http://gcc.gnu.org/.Google ScholarGoogle Scholar
  14. David Gay and Alex Aiken. Memory management with explicit regions. In Proceedings of the 1998 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 313--323, Montreal, Canada, June 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. David Gay and Alex Aiken. Language support for regions. In Proceedings of the 2001 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 70--80, Snowbird, Utah, June 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Wolfram Gloger. Dynamic memory allocator implementations in Linux system libraries. http://www.dent.med.uni-muenchen.de/~wmglo/malloc-slides.html.Google ScholarGoogle Scholar
  17. Dan Grossman, Greg Morrisett, Trevor Jim, Michael Hicks, Yanling Wang, and James Cheney. Region-based memory management in cyclone. In Proceedings of the 2002 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 282--293, Berlin, Germany, June 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Sam Guyer, Daniel A. Jiménez, and Calvin Lin. The C-Breeze compiler infrastructure. Technical Report UTCS-TR01-43, The University of Texas at Austin, November 2001.Google ScholarGoogle Scholar
  19. David R. Hanson. Fast allocation and deallocation of memory based on object lifetimes. In Software Practice & Experience, number 20(1), pages 5--12. Wiley, January 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. David R. Hanson. C Interfaces and Implementation. Addison-Wesley, 1997.Google ScholarGoogle Scholar
  21. Reed Hastings and Bob Joyce. Purify: Fast detection of memory leaks and access errors. In Proceedings of the Winter USENIX 1992 Conference, pages 125--136, December 1992.Google ScholarGoogle Scholar
  22. Mark S. Johnstone and Paul R. Wilson. The memory fragmentation problem: Solved? In International Symposium on Memory Management, pages 26--36, Vancouver, B.C., Canada, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Doug Lea. A memory allocator. http://g.oswego.edu/dl/html/malloc.html.Google ScholarGoogle Scholar
  24. Scott Meyers. Effective C++. Addison-Wesley, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Scott Meyers. More Effective C++. Addison-Wesley, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Bartosz Milewski. C++ In Action: Industrial-Strength Programming Techniques. Addison-Wesley, 2001.Google ScholarGoogle Scholar
  27. Philip A. Nelson. bc - An arbitrary precision calculator language. http://www.gnu.org/software/bc/bc.html.Google ScholarGoogle Scholar
  28. Jeffrey Richter. Advanced Windows: the developer's guide to the Win32 API for Windows NT 3.5 and Windows 95. Microsoft Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Gustavo Rodriguez-Rivera, Mike Spertus, and Charles Fiterman. Conservative garbage collection for general memory allocators. In International Symposium on Memory Management, Minneapolis, Minnesota, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. D. T. Ross. The AED free storage package. Communications of the ACM, 10(8):481--492, 1967. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Colin Runciman and Niklas Rojemo. Lag, drag and postmortem heap profiling. In Implementation of Functional Languages Workshop, Bastad, Sweden, September 1995.Google ScholarGoogle Scholar
  32. SGI. The Standard Template Library for C++: Allocators. http://www.sgi.com/tech/stl/Allocators.html.Google ScholarGoogle Scholar
  33. Ran Shaham, Elliot K. Kolodner, and Mooly Sagiv. Heap profiling for space-efficient Java. In Proceedings of the 2001 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 104--113, Snowbird, Utah, June 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Standard Performance Evaluation Corporation. SPEC2000. http://www.spec.org.Google ScholarGoogle Scholar
  35. Standard Performance Evaluation Corporation. SPEC95. http://www.spec.org.Google ScholarGoogle Scholar
  36. Lincoln Stein, Doug MacEachern, and Linda Mui. Writing Apache Modules with Perl and C. O'Reilly & Associates, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Bjarne Stroustrup. The C++ Programming Language, Second Edition. (Addison-Wesley), 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Suzanne Pierce. PPRC: Microsoft's Tool Box. http://research.microsoft.com/research/pprc/mstoolbox.asp.Google ScholarGoogle Scholar
  39. Mads Tofte and Jean-Pierre Talpin. Region-based memory management. Information and Computation, 132(2):109--176, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Dan N. Truong, François Bodin, and André Seznec. Improving cache behavior of dynamically allocated data structures. In International Conference on Parallel Architectures and Compilation Techniques, pages 322--329, October 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Kiem-Phong Vo. Vmalloc: A general and efficient memory allocator. In Software Practice & Experience, number 26, pages 1--18. Wiley, 1996.Google ScholarGoogle Scholar
  42. Mark Weiser, Alan Demers, and Carl Hauser. The Portable Common Runtime approach to interoperability. In Twelfth ACM Symposium on Operating Systems Principles, pages 114--122, December 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. P. R. Wilson, M. S. Johnstone, M. Neely, and D. Boles. Dynamic storage allocation: A survey and critical review. Lecture Notes in Computer Science, 986, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Benjamin G. Zorn. The measured cost of conservative garbage collection. Software Practice and Experience, 23(7):733--756, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Reconsidering custom memory allocation

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 37, Issue 11
        November 2002
        385 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/583854
        Issue’s Table of Contents
        • cover image ACM Conferences
          OOPSLA '02: Proceedings of the 17th ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications
          November 2002
          396 pages
          ISBN:1581134711
          DOI:10.1145/582419

        Copyright © 2002 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 4 November 2002

        Check for updates

        Qualifiers

        • article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader