Garbage Collection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lasse Skyum

    Garbage Collection

    Hi folks,

    I've been wanting to write a garbagecollecto r for C++ for a little while...
    my idea is that all objects inherited from "CGCObject" will be
    garbage-collected if no longer used.

    So all I would have to do is:
    CMyClass *pTest = new CMyClass(); // CMyClass inherits CGCObject

    My aproach has been the "mark and sweep" algorithm, but I haven't been able
    to come up with anything where no additional programming is needed for the
    programs using CGCObject.

    The reason I don't just use reference-counting is because of the possible
    cyclic references holding objects alive even though they should have been
    deleted.


    Can anyone give some hints or references to existing lib's with similar
    functionality?

    --
    Lasse


  • SenderX

    #2
    Re: Garbage Collection

    > I've been wanting to write a garbagecollecto r for C++ for a little
    while...

    Too late!

    The best garbage collected c++ pointer was already designed a long time ago:

    U.S. patent#: 5,295,262

    [color=blue]
    > My aproach has been the "mark and sweep" algorithm[/color]

    Not needed. Ugly schema anyway.

    [color=blue]
    > The reason I don't just use reference-counting is because of the possible
    > cyclic references holding objects alive even though they should have been
    > deleted.[/color]

    Na.

    [color=blue]
    > Can anyone give some hints or references to existing lib's with similar
    > functionality?[/color]

    The one and only lock-free atomic_ptr, created by Joe Seigh:


    The C++ version:





    The C version( by me ), with ABA prevention code( by me ):



    This is the best lock-free garbage collector out there. Period!



    P.S.

    Here is my lock-free proxy garbage collector:



    This 100% lock-free garbage collector is almost as good as atomic_ptr...


    These lock-free collectors are SMP and HyperThread friendly. "mark and
    sweep" is NOT.

    ;)

    --
    The designer of the experimental, SMP and HyperThread friendly, AppCore
    library.




    Comment

    • Lasse Skyum

      #3
      Re: Garbage Collection

      [color=blue]
      > Too late![/color]
      dahh! I'm always too late... born too young I guess :-P


      Thanks for the links, they seem verry usefull!

      --
      Lasse


      Comment

      Working...