skip to main content
10.1145/1542431.1542437acmconferencesArticle/Chapter ViewAbstractPublication PagesismmConference Proceedingsconference-collections
research-article

Garbage collection in the next C++ standard

Published: 19 June 2009 Publication History

Abstract

C++ has traditionally relied on manual memory management. Sometimes this has been augmented by limited reference counting, implemented in libraries, and requiring use of separate pointer types. In spite of the fact that conservative garbage collectors have been used with C for decades, and with C++ for almost as long, they have not been well-supported by language standards. This in turn has limited their use.
We have led an effort to change this by supporting optional "transparent" garbage collection in the next C++ standard. This is designed to either garbage collect or detect leaks in code using normal unadorned C++ pointers. We initially describe an ambitious effort that would have allowed programmers to explicitly request garbage collection. It faced a number of challenges, primarily in correct interaction with existing libraries relying on explicit destructor invocation. This effort was eventually postponed to the next round of standardization. This initial effort was then temporarily replaced by minimal support in the language that officially allows garbage collected implementations. Such minimal support is included in the current committee draft for the next C++ standard. It imposes an additional language restriction that makes it safe to garbage collect C++ programs. Stating this restriction proved subtle.
We also provide narrow interfaces that make it easy to both correct code violating this new restriction, and to supply hints to a conservative garbage collector to improve its performance. These provide interesting implementation challenges. We discuss partial solutions.

References

[1]
J. F. Bartlett. Compacting garbage collection with ambiguous roots. Lisp Pointers, pages 3--12, April-June 1988.
[2]
D. Blake. Programming languages: Everyone has a favorite one. Dr. Dobb's Journal, 18(3), April 2008.
[3]
H.-J. Boehm. A garbage collector for C and C++. http://www.hpl.hp.com/personal/Hans_Boehm/gc/.
[4]
H.-J. Boehm. Space efficient conservative garbage collection. In SIGPLAN '93 Conference on Programming Language Design and Implementation, pages 197--206, June 1993.
[5]
H.-J. Boehm. Simple garbage-collector-safety. In SIGPLAN'96 Conference on Programming Language Design and Implementation, pages 89--98, June 1996.
[6]
H.-J. Boehm. Fast multiprocessor memory allocation and garbage collection. Technical Report HPL-2000-165, HP Laboratories, December 2000.
[7]
H.-J. Boehm. Reducing garbage collector cache misses. In Proceedings of the 2000 International Symposium on Memory Management, pages 59--64, 2000.
[8]
H.-J. Boehm. Bounding space usage of conservative garbage collectors. In Proceeedings of the Twenty-Ninth Annual ACM Symposium on Principles of Programming Languages, pages 93--100, 2002.
[9]
H.-J. Boehm. Destructors, finalizers, and synchronization. In Proceeedings of the 30th Annual ACM Symposium on Principles of Programming Languages, pages 262--272, 2003.
[10]
H.-J. Boehm. The space cost of lazy reference counting. In Proceeedings of the 31st Annual ACM Symposium on Principles of Programming Languages, pages 210--219, 2004.
[11]
H.-J. Boehm, A. J. Demers, and S. Shenker. Mostly parallel garbage collection. In SIGPLAN'91 Conference on Programming Language Design and Implementation, pages 157--164, June 1991.
[12]
H.-J. Boehm and M. Spertus. N2261: Optimization-robust finalization. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2261.html.
[13]
H.-J. Boehm and M. Spertus. N2310: Transparent programmer-directed garbage collection for c++. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2310.pdf.
[14]
H.-J. Boehm, M. Spertus, and C. Nelson. N2670: Minimal support for garbage collection and reachability-based leak detection (revised). http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2670.htm.
[15]
H.-J. Boehm and M. Weiser. Garbage collection in an uncooperative environment. Software Practice and Experience, 18:807--820, September 1988.
[16]
W. Bright. Digital mars. http://www.digitalmars.com/.
[17]
B. Cantrill and J. Bonwick. Real-world concurrency. ACM Queue, 6(5):16--25, September 2008.
[18]
G. Colvin, B. Dawes, P. Dimov, and D. Adler. Boost smart pointer library. http://www.boost.org/libs/smart\_ptr/.
[19]
D. Detlefs, A. Dosser, and B. Zorn. Memory allocation costs in large C and C++ programs. Software Practice and Experience, 24(6):527--547, 1994.
[20]
J. R. Ellis and D. L. Detlefs. Safe, efficient garbage collection for C++. Technical Report CSL-93-4, Xerox Palo Alto Research Center, September 1993.
[21]
R. Hastings and B. Joyce. Purify: Fast detection of memory leaks and access errors. In Winter Usenix Conference, pages 125--136, 1992.
[22]
H. Hinnant. N2771: Lwg issues. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2771.html.
[23]
M. Hirzel and A. Diwan. On the type accuracy of garbage collection. In Proceedings of the International Symposium on Memory Management 2000, pages 1--11, October 2000.
[24]
ISO/IEC JTC1/SC22/WG21. ISO/IEC 14882, Programming Language - C++ (Oct 2008 committee draft). http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2800.pdf.
[25]
M. Kapur. Using the c/c++garbage collection library, libgc. http://developers.sun.com/solaris/articles/libgc.html.
[26]
P. E. McKenney. Exploiting Deferred Destruction: An Analysis of Read-Copy-Update Techniques in Operating Systems Kernels. PhD thesis, OGI School of Science and Engineering at Oregon Health & Science University, 2004.
[27]
G. Rodriguez-Rivera, M. Spertus, and C. Fiterman. Conservative garbage collection for general memory allocators. In Proceedings of the International Symposium on Memory Management 2000, pages 71--79, October 2000.
[28]
P. Rovner. On adding garbage collection and runtime types to a strongly-typed, statically-checked, concurrent language. Technical Report CSL-84-7, Xerox Palo Alto Research Center, July 1985.
[29]
M. Serrano and H.-J. Boehm. Understanding memory allocation of Scheme programs. In Proceedings of the 2000 International Conference on Functional Programming (ICFP), pages 245--256, 2000.
[30]
D. Vandevoorde. N2073: Modules in c++ (revision 4). http://www.open--std.org/jtc1/sc22/wg21/docs/papers/2006/n2073.pdf.

Cited By

View all
  • (2021)Eclipse OMR garbage collection for tracing JIT-based virtual machinesProceedings of the 31st Annual International Conference on Computer Science and Software Engineering10.5555/3507788.3507826(244-249)Online publication date: 22-Nov-2021
  • (2014)Precise garbage collection for C++ with a non-cooperative compilerProceedings of the 10th Central and Eastern European Software Engineering Conference in Russia10.1145/2687233.2687244(1-8)Online publication date: 23-Oct-2014
  • (2013)Ironclad C++ACM SIGPLAN Notices10.1145/2544173.250955048:10(287-304)Online publication date: 29-Oct-2013
  • Show More Cited By

Recommendations

Reviews

Max Hailperin

Boehm and Spertus, two key insiders, report on the C++ standards committee's progress toward supporting automatic storage reclamation and memory leak detection. However, Boehm and Spertus do far more than merely list the relevant features included in the committee's current draft; they also provide a cogent explanation for why these particular features were included, while others were not. Because garbage collectors need to identify the blocks of memory that are accessible, the draft standard prohibits previously legal actions such as dereferencing a pointer value that was read from an input stream. However, the draft standard does provide an escape valve for programmers who need to write tricky code-they can use a new pair of procedures to explicitly declare reachable memory blocks. Because C++ has a weak type system, storage declared with integral types can contain pointers. In some programs, this can greatly increase the amount of memory fruitlessly examined for pointers. In fact, this examination can be even worse: nonpointer values can be mistaken for pointers. Therefore, the committee's draft gives programmers a way to explicitly declare pointer-free memory areas. To justify these extensions to the C++ standard, Boehm and Spertus explain not only the value they offer, but also the limited cost that they entail. They also describe a more ambitious proposal, and explain why the committee postponed it until the next round of standardization. Online Computing Reviews Service

Access critical reviews of Computing literature here

Become a reviewer for Computing Reviews.

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
ISMM '09: Proceedings of the 2009 international symposium on Memory management
June 2009
158 pages
ISBN:9781605583471
DOI:10.1145/1542431
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]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 19 June 2009

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. C++
  2. garbage collection

Qualifiers

  • Research-article

Conference

ISMM '09
Sponsor:

Acceptance Rates

ISMM '09 Paper Acceptance Rate 15 of 32 submissions, 47%;
Overall Acceptance Rate 72 of 156 submissions, 46%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)13
  • Downloads (Last 6 weeks)1
Reflects downloads up to 10 Nov 2024

Other Metrics

Citations

Cited By

View all
  • (2021)Eclipse OMR garbage collection for tracing JIT-based virtual machinesProceedings of the 31st Annual International Conference on Computer Science and Software Engineering10.5555/3507788.3507826(244-249)Online publication date: 22-Nov-2021
  • (2014)Precise garbage collection for C++ with a non-cooperative compilerProceedings of the 10th Central and Eastern European Software Engineering Conference in Russia10.1145/2687233.2687244(1-8)Online publication date: 23-Oct-2014
  • (2013)Ironclad C++ACM SIGPLAN Notices10.1145/2544173.250955048:10(287-304)Online publication date: 29-Oct-2013
  • (2013)Ironclad C++Proceedings of the 2013 ACM SIGPLAN international conference on Object oriented programming systems languages & applications10.1145/2509136.2509550(287-304)Online publication date: 29-Oct-2013
  • (2013)Efficiency of subtype test in object oriented languages with genericsProceedings of the 8th Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems10.1145/2491404.2491406(4-10)Online publication date: 2-Jul-2013

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media