Using a custom DllMain() was necessary, as the "Dynamic-Link Library Best Practices" advises not to perform some tasks within a DllMain() function and NimMain() calls LoadLibrary(), which is not recommended.
Therefore, the custom DllMain() does not perform any tasks when the dll is loaded, but calls GC_fullCollect() and NimDestroyGlobals() when it is unloaded. For more information on when NimMain() is called, see the initnim module.
If you want to add a custom DllMain() to your needs, compile with -d:mdlldkNoDllMain.
References: