C wrappers for Haskell foreign exports don't have finalizers (causes memory leak).
For each foreign export RTS creates a static C wrapper, which is initialized on
DLL_PROCESS_ATTACH, but it has no finalizer/destructor to be called during
DLL_PROCESS_DETACH. So it will stay alive till the program termination. That's why if one uses a Haskell DLL in their C/C++ project, **consumed memory is not fully released after freeing the library**.
There are four files attached to this ticket.
- **HaskellExports.hs** contains exact one foreign export function;
- **CWrapper.cpp** is supposed to contain wrappers to the Haskell functions, described in HaskellExports.hs, but it doesn't because they make no difference;
- **main.cpp**: here in an endless loop the DLL (built with the help of the script below) is loaded and freed at once. Launched program is crashed in a while (because it runs out of memory);
- **build.sh** is a script for building the library.
[[br]] The main program was built with MSVC 2015.