On Fri, 27 Apr 2012 08:57:52 -0400, Rene Zwanenburg <[email protected]> wrote:

On Friday, 27 April 2012 at 11:53:37 UTC, Simen Kjaeraas wrote:
On Fri, 27 Apr 2012 13:23:00 +0200, Dmitry Olshansky <[email protected]> wrote:

On 27.04.2012 15:15, Rene Zwanenburg wrote:
Since an OpenGL context is owned by one thread, any OpenGL calls made
from other threads will fail. I've wrapped OpenGL 'objects' in D classes
to automate destruction of the underlying object:

How about using structs for GL objects? It's not like you have a hierarchy or interfaces in there.

[snip]


http://d.puremagic.com/issues/show_bug.cgi?id=2834

Heap-allocated structs don't have their destructors called when they're collected.

Good to know, that's quite a serious bug and is open for three years now. Is it that hard to fix?

Yes it's hard. The GC has no access to compile-time type information. It relies on runtime information. The GC is able to call the dtor for classes because classes store a pointer to their typeinfo in the class instance itself (needed for virtual functions).

But since structs do not have virtual functions, and many times they are POD, this is not feasible. The allocator could technically store the type info in the memory block, but it doesn't. Strides recently have been made to make the GC more precise, and in that effort, a path to solving this problem has been opened up.

I suspect with precise GC work, this problem will be solved as a side-effect. Maybe 6 months off, depending on how fervently someone tries to add precise scanning ;)

-Steve

Reply via email to