C++ and garbage collection

Enrico Weigelt weigelt@metux.de
Sat Feb 5 12:51:00 GMT 2011


* Florian Weimer <fw@deneb.enyo.de> wrote:

Hi,

> > My idea is to add some mark+sweep gc (boem-gc ?) and remove (or
> > somehow disable) all delete operations. Does that work safely,
> > or do I have to cope with certain nasty side effects ?
> 
> Performance might change.

Okay, it might block a little time when the GC runs, but as it's
a menu-driven application, this won't matter much, IMHO.

> Object lifetimes are no longer deterministic, and destructors will not
> be called.  This can be a significant issue.

Yes, for examples having to close fd's before unmounting filesystems.
But these places are quite few, already identified and mostly
encapsulated, so I can easily add an direct close (independent of
object lifetimes) instead of the delete operations.

> There are a few cases when the Boehm-Dehmers-Weiser collector won't
> work, for instance if you have got custom memory allocators or use
> some pointer encoding schemes.

That's not the case in my app. Purely C++, plus some additional
libraries which I could review quite easily.


cu
-- 
----------------------------------------------------------------------
 Enrico Weigelt, metux IT service -- http://www.metux.de/

 phone:  +49 36207 519931  email: weigelt@metux.de
 mobile: +49 151 27565287  icq:   210169427         skype: nekrad666
----------------------------------------------------------------------
 Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme
----------------------------------------------------------------------



More information about the Gcc-help mailing list