On Monday, 25 January 2021 at 10:26:20 UTC, frame wrote:
On Monday, 25 January 2021 at 07:58:01 UTC, Vitalii wrote:
Hello everyone! I want to create shared library that buffer
some data and do some calculations, another program will use
it. I wonder how this simplest code lead to crash (freeze) of
dll:
Not tested your code but you have to use
import core.sys.windows.dll;
mixin SimpleDllMain;
Windows ist expecting a DllMain routine and runtime needs to
attach the DLL thread.
Yes. I'm doing it whet add dll.d
(https://wiki.dlang.org/Win32_DLLs_in_D) in compile line, it
contents:
---
import core.sys.windows.windows;
import core.sys.windows.dll;
__gshared HINSTANCE g_hInst;
extern (Windows)
BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID
pvReserved)
{
switch (ulReason)
{
case DLL_PROCESS_ATTACH:
g_hInst = hInstance;
dll_process_attach( hInstance, true );
break;
case DLL_PROCESS_DETACH:
dll_process_detach( hInstance, true );
break;
case DLL_THREAD_ATTACH:
dll_thread_attach( true, true );
break;
case DLL_THREAD_DETACH:
dll_thread_detach( true, true );
break;
default:
}
return true;
}
---
Dll is starting ok. But after freeze after printing number around
64000 (~2^16). When I change assoc.array to simple array of
double[] it freeze after number around 520000 (~2^19), int[] --
1.000.000. So I conclude than dll freeze after exceed some memory
limit about 4 Mb. But I still can't see what I'm doing wrong. Any
ideas?