пн, 27 авг. 2018 г. в 19:46, Phyx <loneti...@gmail.com>:

> Hi,
>
> You're likely just hitting a memory leak, Haskell DLLs and the RTS aren't
> designed to be unload-able, which is why you can't call hs_init again after
> you stop.
>
> The leak happens only when you do a foreign export because foreign exports
> create C wrappers to initializers for each function you export.
>
> https://github.com/ghc/ghc/blob/21f0f56164f50844c2150c62f950983b2376f8b6/compiler/deSugar/DsForeign.hs#L668
>
>
These are marked as static initializers, and as such the CRT will
> initialize them on DLL_PROCESS_ATTACH time. At DLL_PROCESS_DETACH
> time the destructors would be run, but we don't have destructors for these
> initializers, so whatever they did will always persist.
>

Hello!
Thank you very much for such a detailed explanation! Now I gain an insight
into what's happening.



>
> Your use case is fairly uncommon, but file a bug report against the leaks
> anyway. Why do you need to keep loading and unloading the dll?
>

Our goal was to understand whether we're cooking it in a wrong way or
that's the implementation details of the Haskell RTS.
And your answer just suits our goal perfectly. Anyway I will submit a bug
report as you suggested.

Kind regards,
-- 
*Olga Philippskaya.*
_______________________________________________
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Reply via email to