"Garbage collection"

Hi. I have a couple of questions about garbage collection:

What is it?
How do you implement it?
and Is there any point in trying to learn how to do it?

Thanks.
http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)

Mixing C/++ and GC is like mixing Java and inline Assembly.
Pointless, then?
Never mind. I thought it was something I should learn.
Obviously not.
Learn RAII instead.
Thanks.

Oh, that looks quite doable. Thank you.
Last edited on
Hmmm while you cannot specifically have "garbage collection" in C++. There are ways to use specifically designed objects that handle memory de-allocation automatically for you.

Have a look at the boost scoped and shared objects.
http://www.boost.org/doc/libs/1_38_0/libs/smart_ptr/smart_ptr.htm

This is pretty much the same as having garbage collection. Except that the memory is freed when the object goes out of scope, instead of at some undetermined point in the future. You also don't have the overhead of a garbage collector.

What is overhead? I've seen it used many times on the forum but don't actually know what it is :S
Topic archived. No new replies allowed.