Bug 6188 – Add ability to call element dtors to array blocks

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2011-06-21T05:04:00Z
Last change time
2015-12-10T14:57:45Z
Assigned to
schveiguy
Creator
schveiguy

Comments

Comment #0 by schveiguy — 2011-06-21T05:04:39Z
Currently, when an array of structs is created on the heap, the destructor for those structs is not called when the GC collects the memory block. However, this can be fixed by having the runtime store the typeinfo used to create the block inside the block, along with a flag indicating a finalizer. Proposed design: lifetime.d: Store the typeinfo reference in the last bytes of small blocks, beside the length in large blocks. If the typeinfo has no dtor, don't store it. If the typeinfo is stored, mark the block as containing a finalizer. gcx.d: when finalizing a block that has both appendable and finalizer set, call a lifetime.d function which finalizes the array (new function) std.array: Appender should use the finalizer mechanism above to store the typeinfo if necessary. Not sure at this point how it will interact with array runtime. However, there are pending improvements for Appender that may make this easier (see bug 5813).
Comment #1 by schveiguy — 2015-12-10T14:57:45Z
dtor call for array elements has been added as of 2.067