DLLs: Cleaning up

Chris wendlec at tcd.ie
Fri Jul 12 06:15:33 PDT 2013


On Thursday, 11 July 2013 at 19:37:31 UTC, dnewbie wrote:
> On Thursday, 11 July 2013 at 12:58:42 UTC, Chris wrote:
>> I have a DLL written in D I load into a Python application via 
>> ctypes like so:
>>
>> lib = CDLL("mydll")
>>
>> The DLL loads and can be used no problem. However, once the 
>> DLL is discarded of by the program, the program either doesn't 
>> react or crashes. I still haven't worked out how to clean up 
>> the DLL correctly before it is unloaded / detached (from 
>> Python). I guess it's the GC and/or some C stuff I've 
>> overlooked. I have tried both approaches described on this 
>> page: http://dlang.org/dll.html.
>>
>> Maybe someone of yous once had a similar problem and found a 
>> solution. Any hints or suggestions would be appreciated. 
>> Thanks.
>
> Ye. Please try compiling your DLL with GDC.

Thanks for the advice, I might try that later. However, I have 
noticed that my DLL does not cause any errors nor does it crash 
the app when switching between my DLL and other third party 
plugins. There is only one other plugin that crashes the app 
after my dll was active (otherwise there's no crash). I've tried 
several solutions now but to no avail. I don't think it's the 
other plugin's fault, as it works usually fine, but maybe there 
is a conflict somewhere in the dark realms of memory.



More information about the Digitalmars-d-learn mailing list