Boost logo

Boost :

Subject: Re: [boost] request for interest in a garbage collection library
From: Achilleas Margaritis (axilmar_at_[hidden])
Date: 2009-04-20 13:07:29


Mathias Gaunard wrote:
> 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.

No, it does not overload operator new, it only overloads the operator
new for the classes you want to be garbage collected.

> I even wonder how gc_ptr<T>::gc_ptr::(T*) can be a safe constructor at all.

What do you mean exactly?

>
> A fairly terrible design, that has a lot of shortcomings, some of which
> where raised when talking of Boehm GC (basically, bad integration).

What shortcomings do you specifically refer to?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk