free causes exception

Igor via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jan 27 14:35:56 PST 2016


On Wednesday, 27 January 2016 at 14:31:20 UTC, Steven 
Schveighoffer wrote:
> On 1/26/16 4:23 PM, Igor wrote:
>> On Tuesday, 26 January 2016 at 20:17:20 UTC, Steven 
>> Schveighoffer wrote:
>>> [...]
>>
>> um? Memory manager? I am doing it manually C++ style so I 
>> don't have to
>> worry about the god forsaken memory manager. Why is it so 
>> difficult? I
>> create the object and release it when I need to.
>
> As Mike said, I mean whatever you are using for memory 
> management. The class is not responsible for allocating or 
> deallocating itself, just initializing itself and 
> deinitializing itself.
>
> So if you use malloc and free, that is your memory manager.
>
>>
>> I can replace the destroy(f) with free(inline the code) but I 
>> don't see
>> why that should matter. The whole point of destructors is to 
>> do this
>> sort of stuff. That's why they were invented in the first 
>> place!?!
>
> It isn't even this way in C++. No destructors deallocate 'this'.
>
> All D destructors should destroy all the members. And generally 
> speaking, if you ever plan to use a class with the GC, you 
> should only destroy non-GC members. The GC members may already 
> be destroyed.
>
> -Steve

There needs to be better docs on this? Or at least someone needs 
to provide a link! ;)

Why can there be an "deplace" equivalent to emplace?

Everone says it's so easy not to use the GC in D yet I can't seem 
to find any real world examples ;/


More information about the Digitalmars-d-learn mailing list