Blame doc/overview.html

Packit d28291
Packit d28291
<html><head><title>A garbage collector for C and C++</title></head>
Packit d28291
<body>
Packit d28291
Packit d28291
  
Packit d28291
  Interface Overview
Packit d28291
  Tutorial Slides
Packit d28291
  FAQ
Packit d28291
  Example
Packit d28291
  Download
Packit d28291
  License
Packit d28291
  
Packit d28291
Packit d28291

A garbage collector for C and C++

Packit d28291
    Packit d28291
  • Platforms
  • Packit d28291
  • Scalable multiprocessor versions
  • Packit d28291
  • Some collector details
  • Packit d28291
  • Further reading
  • Packit d28291
  • Current users
  • Packit d28291
  • Local Links for this collector
  • Packit d28291
  • Local Background Links
  • Packit d28291
  • Contacts and Mailing List
  • Packit d28291
    Packit d28291
    [ This is an updated version of the page formerly at
    Packit d28291
    <tt>www.hpl.hp.com/personal/Hans_Boehm/gc/</tt>,
    Packit d28291
    before that at
    Packit d28291
    <tt>http://reality.sgi.com/boehm/gc.html</tt>
    Packit d28291
    and before that at
    Packit d28291
    <tt>ftp://ftp.parc.xerox.com/pub/gc/gc.html</tt>. ]
    Packit d28291

    Packit d28291
    The Boehm-Demers-Weiser
    Packit d28291
    conservative Garbage Collector (BDWGC) can
    Packit d28291
    be used as a garbage collecting
    Packit d28291
    replacement for C <tt>malloc</tt> or C++ <tt>new</tt>.
    Packit d28291
    It allows you to allocate memory basically as you normally would,
    Packit d28291
    without explicitly deallocating memory that is no longer useful.
    Packit d28291
    The collector automatically recycles memory when it determines
    Packit d28291
    that it can no longer be otherwise accessed.
    Packit d28291
    A simple example of such a use is given
    Packit d28291
    here.
    Packit d28291

    Packit d28291
    The collector is also used by a number of programming language
    Packit d28291
    implementations that either use C as intermediate code, want
    Packit d28291
    to facilitate easier interoperation with C libraries, or
    Packit d28291
    just prefer the simple collector interface.
    Packit d28291
    For a more detailed description of the interface, see
    Packit d28291
    here.
    Packit d28291

    Packit d28291
    Alternatively, the garbage collector may be used as
    Packit d28291
    a leak detector
    Packit d28291
    for C or C++ programs, though that is not its primary goal.
    Packit d28291

    Packit d28291
    Typically several versions are offered for
    Packit d28291
    downloading:
    Packit d28291
    preview, stable, legacy.
    Packit d28291
    Usually you should use the one marked as the latest stable release.
    Packit d28291
    Preview versions may contain additional features, platform support,
    Packit d28291
    but are likely to be less well tested.
    Packit d28291
    The list of changes for each version is specified on the
    Packit d28291
    releases page.
    Packit d28291

    Packit d28291
    The arguments for and against conservative garbage collection
    Packit d28291
    in C and C++ are briefly
    Packit d28291
    discussed in
    Packit d28291
    issues.html.
    Packit d28291
    The beginnings of a frequently-asked-questions list are
    Packit d28291
    here.
    Packit d28291

    Packit d28291
    The garbage collector code is copyrighted by
    Packit d28291
    Hans-J. Boehm,
    Packit d28291
    Alan J. Demers,
    Packit d28291
    Xerox Corporation,
    Packit d28291
    Silicon Graphics,
    Packit d28291
    and
    Packit d28291
    Hewlett-Packard Company.
    Packit d28291
    It may be used and copied without payment of a fee under minimal restrictions.
    Packit d28291
    See the README file in the distribution or the
    Packit d28291
    license for more details.
    Packit d28291
    IT IS PROVIDED AS IS,
    Packit d28291
    WITH ABSOLUTELY NO WARRANTY EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
    Packit d28291

    Packit d28291
    Empirically, this collector works with most unmodified C programs,
    Packit d28291
    simply by replacing
    Packit d28291
    <tt>malloc</tt> with <tt>GC_malloc</tt> calls,
    Packit d28291
    replacing <tt>realloc</tt> with <tt>GC_realloc</tt> calls, and removing
    Packit d28291
    free calls.  Exceptions are discussed
    Packit d28291
    in issues.html.
    Packit d28291

    Platforms

    Packit d28291
    The collector is not completely portable, but the distribution
    Packit d28291
    includes ports to most standard PC and UNIX/Linux platforms.
    Packit d28291
    The collector should work on Linux, *BSD, recent Windows versions,
    Packit d28291
    MacOS X, HP/UX, Solaris,
    Packit d28291
    Tru64, Irix and a few other operating systems.
    Packit d28291
    Some ports are more polished than others.
    Packit d28291

    Packit d28291
    Irix pthreads, Linux threads, Win32 threads, Solaris threads
    Packit d28291
    (pthreads only),
    Packit d28291
    HP/UX 11 pthreads, Tru64 pthreads, and MacOS X threads are supported
    Packit d28291
    in recent versions.
    Packit d28291

    Separately distributed ports

    Packit d28291
    For MacOS 9/Classic use, Patrick Beard's latest port is available from
    Packit d28291
    <tt>http://homepage.mac.com/pcbeard/gc/</tt>.
    Packit d28291
    (Unfortunately, that's now quite dated.
    Packit d28291
    I'm not in a position to test under MacOS.  Although I try to
    Packit d28291
    incorporate changes, it is impossible for
    Packit d28291
    me to update the project file.)
    Packit d28291

    Packit d28291
    Precompiled versions of the collector for NetBSD are available
    Packit d28291
    here.
    Packit d28291

    Packit d28291
    Debian Linux includes prepackaged
    Packit d28291
    versions of the collector.
    Packit d28291

    Scalable multiprocessor versions

    Packit d28291
    Kenjiro Taura, Toshio Endo, and Akinori Yonezawa have made available
    Packit d28291
    a parallel collector
    Packit d28291
    based on this one.  Their collector takes advantage of multiple processors
    Packit d28291
    during a collection.  Starting with collector version 6.0alpha1
    Packit d28291
    we also do this, though with more modest processor scalability goals.
    Packit d28291
    Our approach is discussed briefly in
    Packit d28291
    <tt>scale.html</tt>.
    Packit d28291

    Some Collector Details

    Packit d28291
    The collector uses a mark-sweep algorithm.
    Packit d28291
    It provides incremental and generational
    Packit d28291
    collection under operating systems which provide the right kind of
    Packit d28291
    virtual memory support.  (Currently this includes SunOS[45], IRIX,
    Packit d28291
    OSF/1, Linux, and Windows, with varying restrictions.)
    Packit d28291
    It allows finalization code
    Packit d28291
    to be invoked when an object is collected.
    Packit d28291
    It can take advantage of type information to locate pointers if such
    Packit d28291
    information is provided, but it is usually used without such information.
    Packit d28291
    See the README and
    Packit d28291
    <tt>gc.h</tt> files in the distribution for more details.
    Packit d28291

    Packit d28291
    For an overview of the implementation, see here.
    Packit d28291

    Packit d28291
    The garbage collector distribution includes a C string
    Packit d28291
    (cord) package that provides
    Packit d28291
    for fast concatenation and substring operations on long strings.
    Packit d28291
    A simple curses- and win32-based editor that represents the entire file
    Packit d28291
    as a cord is included as a
    Packit d28291
    sample application.
    Packit d28291

    Packit d28291
    Performance of the nonincremental collector is typically competitive
    Packit d28291
    with malloc/free implementations.  Both space and time overhead are
    Packit d28291
    likely to be only slightly higher
    Packit d28291
    for programs written for malloc/free
    Packit d28291
    (see Detlefs, Dosser and Zorn's
    Packit d28291
    Memory Allocation Costs in Large C and C++ Programs.)
    Packit d28291
    For programs allocating primarily very small objects, the collector
    Packit d28291
    may be faster; for programs allocating primarily large objects it will
    Packit d28291
    be slower.  If the collector is used in a multi-threaded environment
    Packit d28291
    and configured for thread-local allocation, it may in some cases
    Packit d28291
    significantly outperform malloc/free allocation in time.
    Packit d28291

    Packit d28291
    We also expect that in many cases any additional overhead
    Packit d28291
    will be more than compensated for by decreased copying etc.
    Packit d28291
    if programs are written
    Packit d28291
    and tuned for garbage collection.
    Packit d28291

    Further Reading:

    Packit d28291
    The beginnings of a frequently asked questions list for this
    Packit d28291
    collector are here.
    Packit d28291

    Packit d28291
    The following provide information on garbage collection in general:
    Packit d28291

    Packit d28291
    Paul Wilson's garbage collection ftp archive and GC survey.
    Packit d28291

    Packit d28291
    The Ravenbrook 
    Packit d28291
    Memory Management Reference.
    Packit d28291

    Packit d28291
    David Chase's
    Packit d28291
    GC FAQ.
    Packit d28291

    Packit d28291
    Richard Jones'
    Packit d28291
    Packit d28291
    Garbage Collection Page and
    Packit d28291
    Packit d28291
    his book.
    Packit d28291

    Packit d28291
    The following papers describe the collector algorithms we use
    Packit d28291
    and the underlying design decisions at
    Packit d28291
    a higher level.
    Packit d28291

    Packit d28291
    (Some of the lower level details can be found
    Packit d28291
    here.)
    Packit d28291

    Packit d28291
    The first one is not available
    Packit d28291
    electronically due to copyright considerations.  Most of the others are
    Packit d28291
    subject to ACM copyright.
    Packit d28291

    Packit d28291
    Boehm, H., "Dynamic Memory Allocation and Garbage Collection", Computers in Physics
    Packit d28291
    9, 3, May/June 1995, pp. 297-303.  This is directed at an otherwise sophisticated
    Packit d28291
    audience unfamiliar with memory allocation issues.  The algorithmic details differ
    Packit d28291
    from those in the implementation.  There is a related letter to the editor and a minor
    Packit d28291
    correction in the next issue.
    Packit d28291

    Packit d28291
    Boehm, H., and M. Weiser,
    Packit d28291
    "Garbage Collection in an Uncooperative Environment",
    Packit d28291
    Software Practice & Experience, September 1988, pp. 807-820.
    Packit d28291

    Packit d28291
    Boehm, H., A. Demers, and S. Shenker, "Mostly Parallel Garbage Collection",
    Packit d28291
    Proceedings of the ACM SIGPLAN '91 Conference on Programming Language Design and Implementation,
    Packit d28291
    SIGPLAN Notices 26, 6 (June 1991), pp. 157-164.
    Packit d28291

    Packit d28291
    Boehm, H., "Space Efficient Conservative Garbage Collection",
    Packit d28291
    Proceedings of the ACM SIGPLAN '93 Conference on Programming Language Design
    Packit d28291
    and Implementation, SIGPLAN Notices 28, 6 (June 1993), pp. 197-206.
    Packit d28291

    Packit d28291
    Boehm, H., "Reducing Garbage Collector Cache Misses",
    Packit d28291
     Proceedings of the 2000 International Symposium on Memory Management .
    Packit d28291
    Packit d28291
    Official version.
    Packit d28291
    Packit d28291
    Technical report version.  Describes the prefetch strategy
    Packit d28291
    incorporated into the collector for some platforms.  Explains why
    Packit d28291
    the sweep phase of a "mark-sweep" collector should not really be
    Packit d28291
    a distinct phase.
    Packit d28291

    Packit d28291
    M. Serrano, H. Boehm,
    Packit d28291
    "Understanding Memory Allocation of Scheme Programs",
    Packit d28291
    Proceedings of the Fifth ACM SIGPLAN International Conference on
    Packit d28291
    Functional Programming, 2000, Montreal, Canada, pp. 245-256.
    Packit d28291
    Packit d28291
    Official version.
    Packit d28291
    Packit d28291
    Earlier Technical Report version.  Includes some discussion of the
    Packit d28291
    collector debugging facilities for identifying causes of memory retention.
    Packit d28291

    Packit d28291
    Boehm, H.,
    Packit d28291
    "Fast Multiprocessor Memory Allocation and Garbage Collection",
    Packit d28291
    Packit d28291
    HP Labs Technical Report HPL 2000-165.  Discusses the parallel
    Packit d28291
    collection algorithms, and presents some performance results.
    Packit d28291

    Packit d28291
    Boehm, H., "Bounding Space Usage of Conservative Garbage Collectors",
    Packit d28291
    Proceedings of the 2002 ACM SIGPLAN-SIGACT Symposium on Principles of
    Packit d28291
    Programming Languages, Jan. 2002, pp. 93-100.
    Packit d28291
    Packit d28291
    Official version.
    Packit d28291
    Packit d28291
    Technical report version.
    Packit d28291
    Includes a discussion of a collector facility to much more reliably test for
    Packit d28291
    the potential of unbounded heap growth.
    Packit d28291

    Packit d28291
    The following papers discuss language and compiler restrictions necessary to guaranteed
    Packit d28291
    safety of conservative garbage collection.
    Packit d28291

    Packit d28291
    We thank John Levine and JCLT for allowing
    Packit d28291
    us to make the second paper available electronically, and providing PostScript for the final
    Packit d28291
    version.
    Packit d28291

    Packit d28291
    Boehm, H., "Simple Garbage-Collector-Safety",
    Packit d28291
    Proceedings of the ACM SIGPLAN '96 Conference on Programming Language Design
    Packit d28291
    and Implementation.
    Packit d28291

    Packit d28291
    Boehm, H., and D. Chase, "A Proposal for Garbage-Collector-Safe C Compilation",
    Packit d28291
    Journal of C  Language Translation 4, 2 (December 1992), pp. 126-141.
    Packit d28291

    Packit d28291
    Other related information: 
    Packit d28291

    Packit d28291
    The Detlefs, Dosser and Zorn's Memory Allocation Costs in Large C and C++ Programs.
    Packit d28291
     This is a performance comparison of the Boehm-Demers-Weiser collector to malloc/free,
    Packit d28291
    using programs written for malloc/free.
    Packit d28291

    Packit d28291
    Joel Bartlett's mostly copying conservative garbage collector for C++.
    Packit d28291

    Packit d28291
    John Ellis and David Detlef's
    Packit d28291
    Safe Efficient Garbage Collection for C++
    Packit d28291
    proposal.
    Packit d28291

    Packit d28291
    Henry Baker's paper collection.
    Packit d28291

    Packit d28291
    Slides for Hans Boehm's Allocation and GC Myths talk.
    Packit d28291

    Current users:

    Packit d28291
    Known current users of some variant of this collector include:
    Packit d28291

    Packit d28291
    The runtime system for
    Packit d28291
    GCJ,
    Packit d28291
    the static GNU java compiler.
    Packit d28291

    Packit d28291
    W3m, a text-based web browser.
    Packit d28291

    Packit d28291
    Some versions of the Xerox DocuPrint printer software.
    Packit d28291

    Packit d28291
    The Mozilla project, as leak
    Packit d28291
    detector.
    Packit d28291

    Packit d28291
    The Mono project,
    Packit d28291
    an open source implementation of the .NET development framework.
    Packit d28291

    Packit d28291
    The DotGNU Portable.NET
    Packit d28291
    project, another open source .NET implementation.
    Packit d28291

    Packit d28291
    The Irssi IRC client.
    Packit d28291

    Packit d28291
    The Berkeley Titanium project.
    Packit d28291

    Packit d28291
    The NAGWare f90 Fortran 90 compiler.
    Packit d28291

    Packit d28291
    Elwood Corporation's Eclipse Common Lisp system, C library, and translator.
    Packit d28291

    Packit d28291
    The Bigloo Scheme
    Packit d28291
    and Camloo ML compilers
    Packit d28291
    written by Manuel Serrano and others.
    Packit d28291

    Packit d28291
    Brent Benson's libscheme.
    Packit d28291

    Packit d28291
    The MzScheme scheme implementation.
    Packit d28291

    Packit d28291
    The University of Washington Cecil Implementation.
    Packit d28291

    Packit d28291
    The Berkeley Sather implementation.
    Packit d28291

    Packit d28291
    The Berkeley Harmonia Project.
    Packit d28291

    Packit d28291
    The Toba Java Virtual
    Packit d28291
    Machine to C translator.
    Packit d28291

    Packit d28291
    The Gwydion Dylan compiler.
    Packit d28291

    Packit d28291
    The 
    Packit d28291
    GNU Objective C runtime.
    Packit d28291

    Packit d28291
    Macaulay 2, a system to support
    Packit d28291
    research in algebraic geometry and commutative algebra.
    Packit d28291

    Packit d28291
    The Vesta configuration management
    Packit d28291
    system.
    Packit d28291

    Packit d28291
    Visual Prolog 6.
    Packit d28291

    Packit d28291
    Asymptote LaTeX-compatible
    Packit d28291
    vector graphics language.
    Packit d28291

    More information on the BDWGC primary site

    Packit d28291
    A simple illustration of how to build and
    Packit d28291
    use the collector.
    Packit d28291

    Packit d28291
    Description of alternate interfaces to the
    Packit d28291
    garbage collector.
    Packit d28291

    Packit d28291
    Slides from an ISMM 2004 tutorial about the GC.
    Packit d28291

    Packit d28291
    A FAQ (frequently asked questions) list.
    Packit d28291

    Packit d28291
    How to use the garbage collector as a leak detector.
    Packit d28291

    Packit d28291
    Some hints on debugging garbage collected
    Packit d28291
    applications.
    Packit d28291

    Packit d28291
    An overview of the implementation of the
    Packit d28291
    garbage collector.
    Packit d28291

    Packit d28291
    The data structure used for fast pointer lookups.
    Packit d28291

    Packit d28291
    Scalability of the collector to multiprocessors.
    Packit d28291

    Packit d28291
    Directory containing
    Packit d28291
    the distribution files of all garbage collector releases.
    Packit d28291
    It duplicates
    Packit d28291
    Download page on
    Packit d28291
    GitHub.
    Packit d28291

    More background information

    Packit d28291
    An attempt to establish a bound on space usage of
    Packit d28291
    conservative garbage collectors.
    Packit d28291

    Packit d28291
    Mark-sweep versus copying garbage collectors
    Packit d28291
    and their complexity.
    Packit d28291

    Packit d28291
    Pros and cons of conservative garbage collectors,
    Packit d28291
    in comparison to other collectors.
    Packit d28291

    Packit d28291
    Issues related to garbage collection vs.
    Packit d28291
    manual memory management in C/C++.
    Packit d28291

    Packit d28291
    An example of a case in which garbage collection
    Packit d28291
    results in a much faster implementation as a result of reduced synchronization.
    Packit d28291

    Packit d28291
    Slide set discussing performance of nonmoving
    Packit d28291
    garbage collectors.
    Packit d28291

    Packit d28291
    Packit d28291
    Slide set discussing Destructors, Finalizers, and Synchronization
    Packit d28291
    (POPL 2003).
    Packit d28291

    Packit d28291
    Packit d28291
    Paper corresponding to above slide set
    Packit d28291
    (
    Packit d28291
    Technical Report version).
    Packit d28291

    Packit d28291
    A Java/Scheme/C/C++ garbage collection benchmark.
    Packit d28291

    Packit d28291
    Slides for talk on memory allocation myths.
    Packit d28291

    Packit d28291
    Slides for OOPSLA 98 garbage collection talk.
    Packit d28291

    Packit d28291
    Related papers.
    Packit d28291

    Contacts and new release announcements

    Packit d28291
    GitHub and Stack Overflow are the major two places for communication.
    Packit d28291

    Packit d28291
    Technical questions (how to, how does it work, etc.) should be posted to
    Packit d28291
    Stack Overflow
    Packit d28291
    with "boehm-gc" tag.
    Packit d28291

    Packit d28291
    To contribute, please rebase your code to the latest
    Packit d28291
    master and submit
    Packit d28291
    a pull request to GitHub.
    Packit d28291

    Packit d28291
    To report a bug, or propose (request) a new feature, create
    Packit d28291
    a GitHub issue.
    Packit d28291
    Please make sure it has not been reported yet by someone else.
    Packit d28291

    Packit d28291
    To receive notifications on every release, please subscribe to
    Packit d28291
    Releases RSS feed.
    Packit d28291
    Notifications on all issues and pull requests are available by
    Packit d28291
    watching the project.
    Packit d28291

    Packit d28291
    Mailing lists (bdwgc-announce@lists.opendylan.org, bdwgc@lists.opendylan.org,
    Packit d28291
    and the former gc-announce@linux.hpl.hp.com and gc@linux.hpl.hp.com) are not
    Packit d28291
    used at this moment.  Their content is available in
    Packit d28291
    bdwgc-announce
    Packit d28291
    and
    Packit d28291
    bdwgc
    Packit d28291
    archive files, respectively.
    Packit d28291
    The gc list archive may also be read at
    Packit d28291
    Narkive.
    Packit d28291

    Packit d28291
    Some prior discussion of the collector has taken place on the gcc
    Packit d28291
    java mailing list, whose archives appear
    Packit d28291
    here, and also on
    Packit d28291
    gclist@iecc.com.
    Packit d28291

    </body></html>