A few considerations on garbage collection
Jonathan M Davis via Digitalmars-d
digitalmars-d at puremagic.com
Thu May 1 02:44:04 PDT 2014
On Wed, 30 Apr 2014 20:08:03 -0400
Steven Schveighoffer via Digitalmars-d <digitalmars-d at puremagic.com>
wrote:
> On Wed, 30 Apr 2014 14:15:03 -0400, Dmitry Olshansky
> <dmitry.olsh at gmail.com> wrote:
>
> > IIRC they do, it's only arrays of such that doesn't. Anyhow having
> > such a dangerous construct built-in (new = resource leak) in the
> > language becomes questionable.
>
> No, they don't. Only objects are marked as having a finalizer. The
> finalize flag in the GC assumes that the first size_t in the block is
> a pointer to a vtable. A struct cannot have this.
>
> We need to fundamentally modify how this works if we want finalizers
> for structs to be called, but I think it's worth doing. IIRC,
> Rainer's precise GC does this.
It would be _very_ cool if we could make it so that struct destructors
get run when they're on the GC heap. I'm sure that the fact that
they're not called currently creates a number of subtle bugs when
structs are used which assume that they're destructor is going to be
called when they're destroyed/freed.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list