Garbage Collection, Untraceable Errors...

Mike Parker via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 13 01:45:49 PDT 2016


On Monday, 13 June 2016 at 08:26:34 UTC, cy wrote:

> So... that's my complaint about the D garbage collection. It's 
> frustratingly opaque, impossible to debug, and provides no help 
> whatsoever in its error messages to understanding what went 
> wrong. Garbage collection causes errors after the program has 
> entirely finished, and calling GC.collect() inside a destructor 
> will not only cause the error, it'll completely terminate the 
> program before it finishes the destructor. Speed is great, but 
> debugging with garbage collection is pretty much an endless 
> fount of misery and frustration for me.

While it would be nice to have the location of the error, you can 
be sure that the problem lies in a destructor somewhere. It is 
invalid for destructors of GC-managed objects to touch the GC. 
This is precisely the error you get when it happens.

Compiling with -vgc will tell you the source and line number of 
every place your code touches the GC. If your project is big, 
that may be more helpful than eyeballing all of you destructors.


More information about the Digitalmars-d mailing list