http://d.puremagic.com/issues/show_bug.cgi?id=2858





------- Comment #5 from s...@iname.com  2009-04-19 19:10 -------
(In reply to comment #4)
>> Perhaps better:
>> 
>> The garbage collector runs the destructor for all unreferenced 
>> objects before freeing their memory.
> 
> At program exit the memory usually don't need to get freed, so this 
> suggests that memory should be freed always, which I don't think 
> it's a good idea.

Not quite, because some objects may never become unreferenced.  Moreover, I
realise now there are two possible interpretations of what I said here:

(a) The GC is guaranteed to destruct and free every object that ever becomes
unreferenced in the program's lifetime
(b) The GC, when it runs, destructs and frees every unreferenced object

The underlying difference is whether the GC runs on program exit or not.

>> followed by either the second sentence of your proposed rewrite or 
>> this:
>> 
>> However, destructors are not guaranteed to be run on program exit, 
>> but the programmer can force them to be run by calling gc_term() 
>> immediately before termination of the program.
> 
> Why do you think is a good idea not to guarantee the destructors to 
> be called at program exit?

It depends on your point of view and whether you have any destructors that do
something the OS doesn't do when a program exits anyway.  Moreover, I think
this is what Walter intended once upon a time, though that isn't really an
argument either way.


-- 

Reply via email to