www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - DLL and GC

Hi all,
I've some doubts about the interaction between DLLs and the GC (DMD 1.035).

If I take the example from "D code calling D code in DLLs" with
version=DYNAMIC_LOAD, and I add the following line in the DLL implementation:

...
class MyClass {
    char[] concat(char[] a, char[] b){
        auto socketSet = new SocketSet(); /// >>> Added!
        return a ~ " " ~ b;
    }
...

I've a GPF on program exit, probably for a collection right before exiting the
program.
If I add a std.gc.fullCollect() just before doing the std.gc.endGCHandle(), all
is ok.

Now, I cannot understand why the GC choke when collecting something it
allocated, and if the fullCollect() is mandatory before releasing the gc handle
(and in this case, I think it's better to add it into the documentation
example)...

Comments are welcome!

Paolo Invernizzi
Sep 23 2008