Boost logo

Boost :

Subject: Re: [boost] discussion of garbage collection in C++
From: Kasra (kasra_n500_at_[hidden])
Date: 2009-04-26 22:10:40

Edward Diener wrote:
>Also, for people looking for a runtime envrironment for C++, they can look >at Ch.

Or CERN.ROOT.CINT project.

Either way we are looking at GC in C++ from the wrong direction. I like to know and be able to determine where the memory allocation deallocation occurs. When the constructor and destructor is called using RAII, however, this doesn't mean I shouldn't use GC.

GC is supposed to release unused memory, not to call the destructors of objects; although it does on most implementations.


bool g(int);

for(int i=0; i<10000; i++) {
  // allocate a memory of size = sizeof(Foo)
  // then construct an instance of Foo on that memory
  gc_ptr<Foo> f(new (gc) Foo());

  // if g(i) == true, delete the memory
  if( g(i) )
    operator delete(f, gc);

// delete all of the objects.


The distinction is between construction/destruction of objects and
allocation/deallocation of memory. We let GC to perform allocation/deallocation of memory, while we allow ourselves optionaly
to take control of construction/destruction of the objects allocated on
that memory.

This distinction is so important while everyone ignores :D

-- Kasra


Boost list run by bdawes at, gregod at, cpdaniel at, john at