Precompiling C++ for garbage collection

  • Daniel R. Edelson
Object Oriented Languages
Part of the Lecture Notes in Computer Science book series (LNCS, volume 637)


Our research is concerned with compiler-independent, efficient and convenient garbage collection for C++. Most collectors proposed for C++ have either been implemented in a library or in a compiler. As an intermediate step between those two, this paper proposes using precompilation techniques to augment a C++ source program with code to allow mostly type-accurate garbage collection. There are two key precompiler transformations. The first is automatic generation of smart pointer classes. The precompiler defines the smart pointer classes and the user utilizes them instead of raw pointers. These smart pointers supply functionality that allows the collector to locate the root set for collection. The second transformation augments the C++ program with code that allows the garbage collector to locate internal pointers within objects. This paper describes the precompiler and the garbage collector. The paper includes a brief (1500 word) survey of related techniques.


Garbage Collection Internal Pointer Foreign Object Cell Array Object Orient System 
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.
    ACM. Proc. PLDI '91 (June 1991). SIGPLAN Not. 26(6).Google Scholar
  2. 2.
    Appel, A. W. Runtime tags aren't necessary. In Lisp and Symbolic Computation (1989), vol. 2, pp. 153–162.CrossRefGoogle Scholar
  3. 3.
    Appel, A. W., and Li, K. Virtual memory primitives for user programs. In ASPLOS Inter. Conf. Architectural Support for Programming Languages and Operating Systems (Santa Clara, CA (USA), Apr. 1991), pp. 96–107. SIGPLAN Not. 26(4).Google Scholar
  4. 4.
    Bartlett, J. F. Compacting garbage collection with ambiguous roots. Tech. Rep. 88/2, Digital Equipment Corporation, Western Research Laboratory, Palo Alto, California, Feb. 1988.Google Scholar
  5. 5.
    Bartlett, J. F. Mostly copying garbage collection picks up generations and C++. Tech. Rep. TN-12, DEC WRL, Oct. 1989.Google Scholar
  6. 6.
    Boehm, H.-J. Simple gc-safe compilation. Workshop on GC in Object Oriented Systems at OOPSLA '91, 1991.Google Scholar
  7. 7.
    Boehm, H.-J., Demers, A. J., and Shenker, S. Mostly parallel garbage collection. In Proc. PLDI '91 [1], pp. 157–164. SIGPLAN Not. 26(6).Google Scholar
  8. 8.
    Boehm, H.-J., and Weiser, M. Garbage collection in an uncooperative environment. Soflw. — Pract. Exp. 18, 9 (Sept. 1988), 807–820.Google Scholar
  9. 9.
    Christopher, T. W. Reference count garbage collection. Softw. — Pract. Exp. 14, 6 (1984), 503–508.Google Scholar
  10. 10.
    Coplien, J. Advanced C++ Programming Styles and Idioms. Addison-Wesley, 1992.Google Scholar
  11. 11.
    Demers, A., Weiser, M., Hayes, B., Boehm, H., Bobrow, D., and Shenker, S. Combining generational and conservative garbage collection: Framework and implementations. In Proc. POPL '90 (Jan. 1990), ACM, ACM, pp. 261–269.Google Scholar
  12. 12.
    Detlefs, D. Concurrent garbage collection for C++. Tech. Rep. CMU-CS-90-119, Carnegie Mellon, 1990.Google Scholar
  13. 13.
    Dickman, P. Trading space for time in the garbage collection of actors. In unpublished form, 1992.Google Scholar
  14. 14.
    Dybvig, K. R.The SCHEME Programming Language. Prentice Hall, Englewood Cliffs, N.J., 1987.Google Scholar
  15. 15.
    Dykstra, D. Conventions on the use of ObjectStars, 1992. Private communication.Google Scholar
  16. 16.
    Edelson, D. R. Comparing two garbage collectors for C++. In unpublished form, 1992.Google Scholar
  17. 17.
    Edelson, D. R. Smart pointers: They're smart but they're not pointers. In Proc. Usenix C++ Technical Conference (Aug. 1992), Usenix Association, pp. 1–19.Google Scholar
  18. 18.
    Edelson, D. R., and Pohl, I. A copying collector for C++. In Proc. Usenix C++ Conference [40], pp. 85–102.Google Scholar
  19. 19.
    Ellis, J. Confirmation of unreachability after finalization, 1992. Private communication.Google Scholar
  20. 20.
    Ellis, M. A., and Stroustrup, B. The Annotated C++ Reference Manual. Addison-Wesley, Feb. 1990.Google Scholar
  21. 21.
    Ferreira, P. Garbage collection in C++. Workshop on GC in Object Oriented Systems at OOPSLA '91, July 1991.Google Scholar
  22. 22.
    Ginter, A. Cooperative garbage collectors using smart pointers in the C++ programming language. Master's thesis, Dept. of Computer Science, University of Calgary, Dec. 1991. Tech. Rpt. 91/451/45.Google Scholar
  23. 23.
    Goldberg, B. Tag-free garbage collection for strongly typed programming languages. In Proc. PLDI '91 [1], pp. 165–176. SIGPLAN Not. 26(6).Google Scholar
  24. 24.
    Grossman, E. Using smart pointers for transparent access to objects on disk or across a network, 1992. Private communication.Google Scholar
  25. 25.
    Kafura, D., Washabaugh, D., and Nelson, J. Garbage collection of actors. In Proc. OOPSLA/ECOOP (Oct. 1990), pp. 126–134. SIGPLAN Not. 25(10).Google Scholar
  26. 26.
    Karplus, K. Using if-then-else DAGs for multi-level logic minimization. In Advanced Research in VLSI: Proceedings of the Decennial Caltech Conference on VLSI (Pasadena, CA, 20–22 March 1989), C. L. Seitz, Ed., MIT Press, pp. 101–118.Google Scholar
  27. 27.
    Kennedy, B. The features of the object-oriented abstract type hierarchy (OATH). In Proc. Usenix C++ Conference [40], pp. 41–50.Google Scholar
  28. 28.
    Madany, P. W., Islam, N., Kougiouris, P., and Campbell, R. H. Reification and reflection in C++: An operating systems perspective. Tech. Rep. UIUCDCS-R-92-1736, Dept. of Computer Science, University of Illinois at Urbana-Champaign, Mar. 1992.Google Scholar
  29. 29.
    Maeder, R. E. A provably correct reference count scheme for a symbolic computation system. In unpublished form, 1992.Google Scholar
  30. 30.
    Miller, J. S. Multischeme: A Parallel Processing System Based on MIT Scheme. PhD thesis, MIT, 1987. MIT/LCS/Tech. Rep.-402.Google Scholar
  31. 31.
    Rovner, P. On adding garbage collection and runtime types to a strongly-typed, statically checked, concurrent language. Tech. Rep. CSL-84-7, Xerox PARC, 1984.Google Scholar
  32. 32.
    Russo, V. Garbage collecting an object-oriented operating system kernel. Workshop on GC in Object Oriented Systems at OOPSLA '91, 1991.Google Scholar
  33. 33.
    Russo, V. There's no free lunch in conservative garbage collection of an operating system, 1991. Private communication.Google Scholar
  34. 34.
    Russo, V. Using the parallel Boehm/Weiser/Demers collector in an operating system, 1991. Private communication.Google Scholar
  35. 35.
    Shapiro, M., Dickman, P., and Plainfossé, D. Robust, distributed references and acyclic garbage collection. In Symp. on Principles of Distributed Computing (Vancouver, Canada, Aug. 1992), ACM.Google Scholar
  36. 36.
    Shapiro, M., Gourhant, Y., Habert, S., Mosseri, L., Ruffin, M., and Valot, C. SOS: An object-oriented operating system—assessment and perspectives. Comput. Syst. 2, 4 (Dec. 1989), 287–338.Google Scholar
  37. 37.
    Shapiro, M., Maisonneuve, J., and Collet, P. Implementing references as chains of links. In Workshop on Object Orientation in Operating Systems (1992). To appear.Google Scholar
  38. 38.
    Stroustrup, B. The evolution of C++ 1985 to 1987. In Proc. Usenix C++ Workshop (Nov. 1987), Usenix Association, pp. 1–22.Google Scholar
  39. 39.
    Stroustrup, B. The C+ + Programming Language, 2nd ed. Addison-Wesley, 1991.Google Scholar
  40. 40.
    Usenix Association.Proc. Usenix C++ Conference (Apr. 1991).Google Scholar
  41. 41.
    Wentworth, E. P. An environment for investigating functional languages and implementations. PhD thesis, University of Port Elizabeth, 1988.Google Scholar
  42. 42.
    Wentworth, E. P. Pitfalls of conservative garbage collection. Softw. — Pract. Exp. (July 1990), 719–727.Google Scholar
  43. 43.
    Yasugi, M., and Yonezawa, A. Towards user (application) language-level garbage collection in object-oriented concurrent languages. Workshop on GC in Object Oriented Systems at OOPSLA '91, 1991.Google Scholar
  44. 44.
    Zorn, B. The measured cost of conservative garbage collection. Tech. Rep. CU-CS-573-92, University of Colorado at Boulder, 1992.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1992

Authors and Affiliations

  • Daniel R. Edelson
    • 1
  1. 1.INRIA Project SORLe Chesnay CedexFrance

Personalised recommendations