September 09, 2015
On Wednesday, 9 September 2015 at 15:24:57 UTC, Q wrote:
> I thought that is not guaranteed, according to the docs?

It is possible that the GC will never actually run, but you can force it to if you need it to by calling GC.collect at any time.
September 09, 2015
On Wednesday, 9 September 2015 at 15:32:58 UTC, Adam D. Ruppe wrote:
> On Wednesday, 9 September 2015 at 15:24:57 UTC, Q wrote:
>> I thought that is not guaranteed, according to the docs?
>
> It is possible that the GC will never actually run, but you can force it to if you need it to by calling GC.collect at any time.

Yes, but according to the specs it is not guaranteed that the GC calls the DTor if the Object is collected.
September 09, 2015
On Wednesday, 9 September 2015 at 15:37:50 UTC, Q wrote:
> Yes, but according to the specs it is not guaranteed that the GC calls the DTor if the Object is collected.

Where? This page says pretty plainly:

http://dlang.org/class.html#destructors

"The garbage collector calls the destructor function when the object is deleted."

(this is arguably a mistake, dtor and finalizer being the same thing have been a problem before, but it does say that)

This sentence: "The garbage collector is not guaranteed to run the destructor for all unreferenced objects. " is because the GC is conservative and has a few exceptions in what it covers. But if you aren't one of those exceptions (data segment, or pinned by a false pointer (very rare in 64 bit btw), it will be collected and if it is collected, the dtor is run.
September 09, 2015
On Wednesday, 9 September 2015 at 15:37:50 UTC, Q wrote:
> Yes, but according to the specs it is not guaranteed that the GC calls the DTor if the Object is collected.

Note that I believe this is the same as in Java (though not C#, interestingly enough). In Java an object's destructor is not guaranteed to run.
1 2
Next ›   Last »