|
Boost : |
Subject: Re: [boost] request for interest in a garbage collection library
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2009-04-18 07:16:31
Jonas Persson wrote:
> The following example gives an access violation on windows:
>
> ----------------------------------------------
> class Foo : public gc_object<Foo> {
> public:
> gc_ptr<Foo> m_next;
> std::string m_name;
>
> Foo(std::string name) : m_name(name) {}
>
> ~Foo() {
> m_next->lastGoodbye();
> }
>
> void lastGoodbye() { std::cout << "Bye " << m_name; }
> };
> void test_cycle() {
> gc_ptr<Foo> foo1 = new Foo("foo 1");
> foo1->m_next = new Foo("foo 2");
> foo1->m_next->m_next = foo1;
>
> foo1 = 0;
> gc::collect();
> }
So that library overloads operator new, meaning all memory becomes
garbage collected, unlike what I understood from what was answered to
one of my other posts.
I even wonder how gc_ptr<T>::gc_ptr::(T*) can be a safe constructor at all.
A fairly terrible design, that has a lot of shortcomings, some of which
where raised when talking of Boehm GC (basically, bad integration).
The funny thing is that the right way to do GC in C++ has been known for
a long time, but for some reason people still want to do it some other way.
C++/CLI, despite its evilness, does it right. Bastek's library (SGCL)
seems to do it somewhat right too.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk