GC object finalization not guaranteed
Unknown W. Brackets
unknown at simplemachines.org
Sat Apr 18 16:16:35 PDT 2009
The simple solution is this:
1. If your class object only involves memory, freed OS handles, etc., it
should be used as-is. This is most class objects. Destructors are
needed to clamp resource use (see File class.)
2. If your class object involves hardware handles, transactional
assurance, or data integrity, it must be scoped. This is the same as it
was in C, except D has better constucts for it (see scope.)
I don't see the problem. For the majority of objects that only involve
memory, life is easier. For the rest, life is still easier (just not as
much.)
-[Unknown]
Leandro Lucarella wrote:
> I've just found out[1] this[2]:
>
> The garbage collector is not guaranteed to run the destructor for
> all unreferenced objects.
>
> Is there any reason why D can't guarantee that all finalizers will be
> called, at least when the program ends?
>
> [1] http://proj.llucax.com.ar/blog/dgc/blog/post/-43101db1
> [2] http://www.digitalmars.com/d/1.0/class.html#destructors
>
More information about the Digitalmars-d
mailing list