On Saturday, 27 October 2012 at 01:03:57 UTC, Rob T wrote:
On Friday, 26 October 2012 at 23:10:48 UTC, bearophile wrote:
Rob T:

Is this happening with dmd 2.060 as released?

I'm using 2.061alpha git head, but I guess the situation is the same with dmd 2.060. The code is linked in my post, so trying it is easy, it's one small module.

Bye,
bearophile

I tried it with dmd 2.60 (released), and gdc 4.7 branch. I tried to check if memory was being freed by creating a struc destructor for JavaMemoryTrade, but that did not work as expected, leading me down the confusing and inconsistent path of figuring out why destructors do not get called when memory is freed.

Long story short, I could not force a struct to execute its destructor if it was allocated on the heap unless I used delete. I tried destroy and clear, as well as GC.collect and GC.free(), nothing else worked.

Memory heap management as well as struct destructors appear to be seriously broken.

--rt

I made a mistake. The clear and destroy operations require that a pointer to a struc be manually dereferenced. What I don't understand is why the compiler allows you to pass a -not- dereferenced pointer to clear and destroy, this looks like a bug to me. It should either work just like a class reference does, or it should refuse to compile.

I'm sure you've heard this many times before, but I have to say that it's very confusing when struct pointers behave exactly like class references, but not always.

--rt


Reply via email to