Segmentation fault on closing file in destructor

Tom Kazimiers 2voodoo at gmx.de
Tue Sep 28 01:12:19 PDT 2010


Hi Jérôme,

On 09/26/2010 10:59 PM, "Jérôme M. Berger" wrote:
> 	The way I see it, there are two possible situations:
> 
> 1. You really need precise control as to when the file is closed. In
> that case, your class contains an explicit cleanup function that you
> call before dropping the last reference and you can close the file
> at that time;
> 
> 2. You only need to be sure that the file gets closed at some point
> but it doesn't really signify when. In that case, you let the GC
> collect your class and you don't close the file. Eventually the GC
> will collect the std.stream.File instance which will result in
> calling its destructor which will close the file without your
> needing to do anything about it.

That are probably the two choices I have, yes. I already have such a
cleanup function and will probably go for that.

Thanks,
Tom


More information about the Digitalmars-d-learn mailing list