Garbage Collection

L

Lasse Skyum

Hi folks,

I've been wanting to write a garbagecollector 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?
 
S

SenderX

I've been wanting to write a garbagecollector 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

My aproach has been the "mark and sweep" algorithm

Not needed. Ugly schema anyway.

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.
Na.


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

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


The C++ version:

http://groups.google.com/[email protected]&rnum=1



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

http://appcore.home.comcast.net/src/AtomicPtr.c

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



P.S.

Here is my lock-free proxy garbage collector:

http://intel.forums.liveworld.com/thread.jsp?forum=242&thread=6721

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.

;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top