Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Third party Solution for Garbage Collection in Delphi

Is there any third party solution , VCL ,Plugins etc to do automatic garbage collection in Delphi for win32

like image 807
VibeeshanRC Avatar asked Dec 01 '22 04:12

VibeeshanRC


2 Answers

You can use interfaces for doing such garbage collection.

If you use interfaces and not classes, you don't have to put an explicit try...finally block, with a call to the free method in the finally section. The compiler will generate it for you, just like with regular string methods.

You can extend this trick to every object, with code like the one published in http://edn.embarcadero.com/article/28217

But this won't be a full garbage collector, like in java or DotNet. It's only reference counting.

IMHO full garbage collector is evil. Managing memory is not difficult in Delphi. You'll type a little more, but in all cases, the performance and global memory consummation will be better with no garbage collector.

like image 89
Arnaud Bouchez Avatar answered Dec 04 '22 22:12

Arnaud Bouchez


There is API for Boehm Garbage Collector for Delphi. But it will work only on Delphi <=7 and without FastMM.

like image 29
Linas Avatar answered Dec 04 '22 23:12

Linas