F*cked by memory corruption after assiging value to associative array
frame
frame86 at live.com
Mon Jan 25 16:44:40 UTC 2021
On Monday, 25 January 2021 at 16:14:05 UTC, vitamin wrote:
> If created on the default way mean allocated with new (=> GC)
> then I don't known where is problem, but if the object is
> allocated with other way, for example malloc, some allocator
> then you need tell GC about that object with GC.addRange.
Yes with simple new operator.
Forgot to mention: the DLL itself calls a DLL.
I made following observation, don't know if it makes any sense:
Assuming that executable and DLL have their own GC instance, it
seems that the --DRT option is ignored by DLLs or they do not see
the command line, idk.
But using
extern (C) __gshared string[] rt_options = ["gcopt=gc:manual"];
in main and DLLs, keeps the memory intact.
Setting gc:conservative on a DLL corrupts again. Also
GC.profileStats.numCollections says that there are cycles when
the memory gets corrupted.
So that means that GC.addRoot() isn't "global" and must be called
after the DLL function has returned the object to adapt it or
within the DLL itself? or both?
More information about the Digitalmars-d-learn
mailing list