Question about destructor of database and multiple use access

Dechcaudron via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 28 08:02:58 PDT 2016


On Thursday, 28 July 2016 at 14:43:32 UTC, Lodovico Giaretta 
wrote:
> No! Never run important finalization in a class destructor! The 
> GC is not obliged to run the destructors, so you may end up 
> with your objects destroyed but the connections still open. For 
> this kind of important things, you have to do them manually.

I always thought that the moment of finalization is undetermined, 
but that the GC does indeed run the destructor... Weird, I'll 
have to look into that. After all what would be the point of 
destructors if they are not guaranteed to be run?

Still, if you are to manually call a cleanup method, you might as 
well call destroy on the instance to force the destructor to run 
right away, right? Not that it makes any difference to call 
instance.cleanup() or destroy(instance) so long as cleanup and 
the destructor contain the same code.




More information about the Digitalmars-d-learn mailing list