C++ and garbage collection
Enrico Weigelt
weigelt@metux.de
Sat Feb 5 14:37:00 GMT 2011
* Lawrence Crowl <crowl@google.com> wrote:
> If your problem is leaking memory, and you aren't playing games
> with your pointers, then you can just add in the Boehm collector,
> leaving the deletes in place. This approach will leave the program
> working pretty much as before, but with less memory.
>
> If your problem is using objects after you have freed them, then you
> have a much harder problem.
I simply want to get rid of the whole deallocation issue at all
(never having to care about this anymore, making the code smaller
and so easier to maintain).
> Many C++ programs do real work in the destructors (like closing
> files) and removing the delete operations would disable that code.
As said in my prev. mail: these are only few cases where this
matters (files on external storages which are mounted/unmounted
by the application) - these are only few, well known places,
which I easily could refactor.
> One viable approach is to modify the uses of pointers into shared_ptr
> (from TR1 or boost) and then add the Boehm collector. This process
> takes work, because changing all pointers won't work and changing
> none won't buy you anything.
Guess this would take a lot of work and add more dependencies
(than just the relatively small boehm-gc lib) ...
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