[Gc] object collected while still in use - test case

MenTaLguY mental at rydia.net
Thu Oct 18 09:55:47 PDT 2007


On Thu, 18 Oct 2007 22:13:39 +1300, "Bruce Hoult" <bruce at hoult.org> wrote:
> Fairly obviously, the STL std::vector class is using malloc() to
> allocate its memory.  You need to find a way to make it use GC memory
> so that it is traced for pointers.

Specifically, that means using a custom STL allocator for vector,
as provided in gc_allocator.h.

Depending on whether the vector itself is allocated in collectable
storage, that would mean either (for the collectable case):

 std::vector<Foo *, gc_allocator<Foo *> >

or (for the uncollectable case):

 std::vector<Foo *, traceable_allocator<Foo *> >

-mental



More information about the Gc mailing list