GC is not the darling of. Net-a garbage collector for C and C ++

Source: Internet
Author: User
Tags tru64
ArticleDirectory
    • Separately distributed ports
Http://www.hpl.hp.com/personal/Hans_Boehm/gc/

Interface Overview Tutorial slides FAQ Example Download License
A Garbage Collector for C and C ++
    • Where to get the Collector
    • Platforms
    • Scalable multiprocessor versions
    • Some collector details
    • Further reading
    • Current users
    • Local links for this collector
    • Local background links
    • Contacts and mailing list

[This is an updated version of the page formerlyHttp://reality.sgi.com/boehm/gc.htmlAnd before thatFtp://parcftp.xerox.com/pub/gc/gc.html.]

The Boehm-Demers-Weiser conservative garbage collector can be used as a garbage collecting replacement for CMallocOr C ++New. It allows you to allocate memory basically as you normally wowould, without explicitly deallocating memory that is no longer useful. the collector automatautomatically recycles memory when it determines that it can no longer be otherwise accessed. A simple example of such a use is given here.

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

Alternatively, the Garbage Collector may be used as a leak detector for C or C ++ programs, though that is not its primary goal.

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

Empirically, this collector works with most unmodified C Programs, simply by replacingMallocWithGc_mallocCILS, replacingReallocWithGc_reallocCILS, and removing free CILS. Exceptions are discussed in issues.html.

Where to get the Collector

Typically several versions will be available. Usually you shoshould first try to useGc_source/gc.tar.gz, Which is normally an older, more stable version.

If that fails, try the latest explicitly numbered version inGc_source/. Later versions may contain additional features, platform support, or bug fixes, but are likely to be less well tested. Note that versions containing the lettersAlphaAre even less well tested than others, especially on non-HP platforms.

The latest experimental version of the source code is now maintained on the SourceForge site (project "bdwgc"). It can be browsed here.

To anonymously check out a CVS version use:
CVS-D: pserver: anonymous@bdwgc.cvs.sourceforge.net:/cvsroot/bdwgc Login
(Just hit return in response to the password prompt. Then :)
CVS-Z3-D: pserver: anonymous@bdwgc.cvs.sourceforge.net:/cvsroot/bdwgc Co-P bdwgc

Maintainers can check out a version for development
CVS-Z3-D: ext: <Name> @ bdwgc.cvs.sourceforge.net:/cvsroot/bdwgc Co-P bdwgc
WithCvs_rshSet to SSH, or whatever is needed to satisfy your firewall.

A slightly older version of the garbage collector is now also encoded as part of the GNU Compiler distribution. The source code for that version is available for browsing here.

The garbage collector code is copyrighted by Hans-J. boehm, Alan J. demers, Xerox Corporation, Silicon Graphics, and Hewlett-Packard Company. it may be used and copied without payment of a specified under minimal restrictions. see the README file in the distribution or the license for more details.It is provided as is, with absolutely no warranty expressed or implied. Any use is at your own risk.

Platforms

The collector is not completely portable, but the distribution has des Ports to most standard PC and Unix/Linux platforms. the collector shocould work on Linux, * BSD, recent Windows versions, MacOS X, HP/UX, Solaris, Tru64, IRIX and a few other operating systems. some ports are more polished than others. there are instructions for porting the collector to a new platform.

IRIX pthreads, Linux threads, Win32 threads, Solaris threads (Old Style and pthreads), HP/UX 11 pthreads, Tru64 pthreads, and MacOS X threads are supported in recent versions.

Separately distributed ports

For MACOs 9/classic use, Patrick beard's latest port is available fromHttp://homepage.mac.com/pcbeard/gc/. (Unfortunately, that's now quite dated. i'm not in a position to test under MACOs. although I try to induplicate ate changes, it is impossible for me to update the project file .)

Precompiled versions of the collector For NetBSD are available here or here.

Debian Linux versions des prepackaged versions of the collector.

Scalable multiprocessor versions

Kenjiro Taura, Toshio Endo, and akinori Yonezawa have made available a parallel Collector Based on this one. their collector takes advantage of multiple processors during a collection. starting with collector version 6.0alpha1 we also do this, though with more modest processor scalability goals. our approach is discussed briefly inScale.html.

Some collector details

The collector uses a mark-sweep algorithm. it provides incremental and generational collection under operating systems which provide the right kind of virtual memory support. (Currently this primary des SunOS [45], Irix, OSF/1, Linux, and windows, with varying restrictions .) it allowsFinalizationCode to be invoked when an object is collected. It can take advantage of type information to locate pointers if such information is provided, but it is usually used without such information. ee the README andGC. hFiles in the distribution for more details.

For an overview of the implementation, see here.

The garbage collector distribution contains des a c string (Cord) Package that provides for fast concatenation and substring operations on long strings. A simple curses-And win32-based editor that represents the entire file as a cord is wrongly ded as a sample application.

Performance of the nonincremental collector is typically competitive with malloc/free implementations. both space and time overhead are likely to be only slightly higher for programs written for malloc/free (see detlefs, dosser and Zorn's memory allocation costs in large C and C ++ programs .) for programs allocating primarily very small objects, the Collector may be faster; For programs allocating primarily large objects it will be slower. if the Collector is used in a multithreaded environment and configured for thread-local allocation, it may in some cases significantly outperform malloc/free allocation in time.

We also precise CT that in our cases any additional overhead will be more than compensated for by decreased copying etc. If programs are written and tuned for garbage collection.

Further reading:

The beginnings of a Frequently Asked Questions list for this collector are here.

The following provide information on garbage collection in general:

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

The ravenbrook memory management reference.

David Chase's gc faq.

Richard Jones 'gc page and his book.

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

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

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

Boehm, H., "dynamic memory allocation and garbage collection ",Computers in physics 9, 3, May/Jun 1995, pp. 297-303. this is directed at an otherwise sophisticated audience unfamiliar with memory allocation issues. the Algorithmic details differ from those in the implementation. there is a related letter to the editor and a minor correction in the next issue.

Boehm, H., and M. Weiser, "garbage collection in an uncooperative environment ",Software Practice & experience, September 1988, pp. 807-820.

Boehm, H., A. Demers, and S. Shenker, "mostly parallel garbage collection", Proceedings of the ACM sigplan '91 Conference on programming language design and implementation,Sigplan notices 26, 6 (June 1991), pp. 157-164.

Boehm, H., "space efficient conservative garbage collection", Proceedings of the ACM sigplan '93 Conference on programming language design and implementation,Sigplan notices 28, 6 (June 1993), pp. 197-206.

Boehm, H., "cing Garbage Collector cache misses ",Proceedings of the 2000 International Symposium on Memory Management. Official version. technical Report version. describes the prefetch strategy inreceivated into the Collector for some platforms. explains why the sweep phase of a "mark-sweep" collector shocould not really be a distinct phase.

M. Serrano, H. Boehm, "Understanding memory allocation of scheme programs ",Proceedings of the maximum th ACM sigplan International Conference on functional programming, 2000, Montreal, Canada, pp. 245-256. Official version. Earlier Technical Report version. Could des some discussion of the collector debugging facilities for identifying causes of memory retention.

Boehm, H., "Fast multiprocessor memory allocation and garbage collection", HP Labs Technical Report hpl 2000-165. Discusses the parallel collection algorithms, and presents some performance results.

Boehm, H., "bounding space usage of conservative garbage collectors ",Proceeedings of the 2002 ACM SIGPLAN-SIGACT Symposium on principles of programming ages, Jan. 2002, pp. 93-100. Official version. Technical Report version. Discussion des a collector facility to much more reliably test for the potential of unbounded heap growth.

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

We thank John Levine and jclt for allowing us to make the second paper available electronically, and providing postscript for the final version.

Boehm, H., ''simple garbage-collector-Safety '', Proceedings of the ACM sigplan '96 Conference on programming language design and implementation.

Boehm, H., and D. Chase, ''a proposal for garbage-collector-safe C compilation '',Journal of c Language Translation 4, 2 (decemeber 1992), pp. 126-141.

Other related information:

The detlefs, dosser and Zorn's memory allocation costs in large C and C ++ programs. this is a performance comparison of the Boehm-Demers-Weiser collector to malloc/free, using programs written for malloc/free.

Joel Bartlett's mostly copying conservative Garbage Collector for C ++.

John Ellis and David Detlef's safe efficient garbage collection for C ++ proposal.

Henry Baker's paper collection.

Slides for Hans Boehm's allocation and GC myths talk.

Current users:

Known current users of some variant of this collector include:

The runtime system for gcj, the static GNU Java compiler.

W3m, a text-based Web browser.

Some versions of the Xerox docuprint printer software.

The Mozilla project, as leak detector.

The Mono Project, an open source implementation of the. NET development framework.

The dotgnu portable. Net project, another open source. Net implementation.

The irssi IRC client.

The Berkeley titanium project.

The nagware f90 Fortran 90 compiler.

Elwood Corporation's eclipse Common Lisp system, C library, and translator.

The bigloo scheme and camloo ml compilers written by Manuel Serrano and others.

Brent Benson's libscheme.

The mzscheme scheme implementation.

The University of Washington Cecil implementation.

The Berkeley sather implementation.

The Berkeley Harmonia project.

The Toba Java Virtual Machine to C translator.

The gwydion Dylan compiler.

The GNU Objective C runtime.

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

The Vesta configuration management system.

Visual Prolog 6.

Asymptote latex-compatible vector graphics language.

More collector information at this site

A simple practice of how to build and use the Collector ..

Description of alternate interfaces to the garbage collector.

Slides from an ismm 2004 tutorial about the GC.

A faq (Frequently Asked Questions) list.

How to Use the garbage collector as a leak detector.

Some hints on debugging garbage collected applications.

An overview of the implementation of the garbage collector.

Instructions for porting the collector to new platforms.

The data structure used for fast pointer lookups.

Scalability of the collector to multiprocessors.

Directory containing Garbage Collector source.

More background information at this site

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

Mark-sweep versus copying garbage collectors and their complexity.

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

Issues related to garbage collection vs. Manual memory management in C/C ++.

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

Slide set discussing performance of nonmoving garbage collectors.

Slide set discussingDestructors, finalizers, and Synchronization(Popl 2003 ).

Paper corresponding to abve slide set. (Technical Report version .)

A Java/scheme/C ++ garbage collection benchmark.

Slides for talk on memory allocation myths.

Slides for oopsla 98 garbage collection talk.

Related papers.

Contacts and mailing list

We have recently set up two mailing list for collector announcements and discussions:

    • Gc-announce@linux.hpl.hp.com is used for announcements of new versions. postings are restricted. We recommend CT this to always remain a very low volume list.
    • Gc@linux.hpl.hp.com is used for discussions, bug reports, and the like. subscribers may post. On-topic posts by nonsubscribers will usually also be accepted, but it may take some time to review them.

To subscribe to these lists, send a mail message containing the word "subscribe" to gc-announce-request@linux.hpl.hp.com or to gc-request@linux.hpl.hp.com. (Please ignore the instructions about web-based subtasks. the listed web site is behind the HP firewall .)

The archives for these lists appear here. The GC list archive may also be read at gmane.org.

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

Comments and bug reports may also be sent to (Hans.Boehm@hp.com) or (boehm@acm.org), but the GC mailing list is usually preferred.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.