A few questions regarding GC.malloc

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Sep 26 11:03:40 PDT 2014


On 9/25/14 6:03 PM, Sean Kelly wrote:
> On Thursday, 25 September 2014 at 21:43:53 UTC, monarch_dodra wrote:
>> On Thursday, 25 September 2014 at 20:58:29 UTC, Gary Willoughby wrote:
>>> What does BlkAttr.FINALIZE do when used in the GC.malloc call?
>>
>> I have no idea. I think its for classes though, since we (currently)
>> don't finalize structs anyways.
>
> Yes it's for memory blocks containing class instances.  It basically
> tells the GC to call Object.~this() when collecting the block.

Just to add to Sean's statement, don't use this flag. It will crash the 
runtime, unless you have properly set up the classinfo pointer :) It 
does NOT work on structs, though I think there is a PR in the works to 
have structs destroyed from the GC.

-Steve


More information about the Digitalmars-d-learn mailing list