Click here to Skip to main content
15,895,777 members
Articles / Desktop Programming / MFC

Portable thread-based garbage collection library, for C++

Rate me:
Please Sign up or sign in to vote.
4.47/5 (6 votes)
19 May 20065 min read 31.3K   331   21  
a description of LibGC, a portable thread-based garbage collection library for C++
#ifndef LIBGC__DOXYGEN_HPP
#define LIBGC__DOXYGEN_HPP


/** \mainpage LibGC

    \section intro Introduction
    
    LibGC is a portable garbage collection library. 
    
    \subsection features Features
    
    <ul>
    <li>thread-based garbage collection.</li>
    <li>precise collection.</li>
    <li>uses the mark & sweep algorithm.</li>
    <li>portable; uses no low-level O/S-specific features.</li>
    <li>no dependencies; headers only.</li>
    <li>weak pointers.</li>
    <li>garbage-collected strong and weak arrays.</li>
    <li>customizeable garbage collection with user-defined finalize and mark callbacks.</li>
    <li>wrapper class for non-garbage-collected classes.</li>
    </ul>

    \subsection why_use Why to use it?
    
    <ul>
    <li>if you want to do a project where you do not want to think about memory management...</li>
    <li>if your project has complex cyclic data structures...</li>
    <li>if you do not want to use an "industrial strength" but huge garbage collector...</li>
    <li>if your compiler is not supported by the other collectors...</li>
    </ul>
    
    ...then this library is ideal for you.
    
    \subsection important_notes Important Notes
    
    <ol>
    <li>The library can not be applied on existing code unless the code is modified; 
        the library uses special classes to achieve its functionality.</li>
    <li>performance may be not the same as if garbage collection was supported natively;
        since it is not possible for user code to know the exact position of pointers,
        some extra work is needed.</li>
    <li>all garbage-collected objects should be allocated on the heap; <b>garbage collected objects
        must not be allocated on the stack or as by-value members of other objects</b>. If this principle
        is not followed, the result is, at best, undefined.</li>
    <li>each thread shall have its own collector; inter-thread collection is not supported, and it will
        never be supported (unless C++ has a standard thread library, something highly unlikely).</li>
    </ol>
    
    \section installation_and_use Installation and Use
    
    Decompress the contents of the compressed file into a directory of your liking, then include the
    file <code>libgc.hpp</code> in your project from that directory.

    \section tutorial Tutorial
    
    \section licence Licence
    
    The library uses <a href="http://www.opensource.org/licenses/lgpl-license.php">the LGPL licence.</a>.
    
    \section links Links
    
    <p><a href="http://sourceforge.net/projects/libgc">Sourceforge project page</a></p>
    <p><a href="http://www.hpl.hp.com/personal/Hans_Boehm/gc/">Hans-Boehm garbage collector</a></p>
 */


#endif //LIBGC__DOXYGEN_HPP

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
Greece Greece
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions