• Advertisement

Archived

This topic is now archived and is closed to further replies.

[java] Unloading a DLL

This topic is 6268 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a Java tool that acts as a plugin to a 3D modeling app. I use JNI for most of the processing that the plugin does. When the plugin is executed, the host app doesn''t terminate its VM (of course), so the JNI DLL remains in memory. Unfortunately, I''d prefer for the DLL to be reinitialized every time the plugin is run. This would make things a lot easier for me. Does anyone know if (and how) I can manually unload a DLL?

Share this post


Link to post
Share on other sites
Advertisement
I may be wrong, but I believe you are at the mercy of the particular VM you are running on. I''m assuming between invocations of the plugin where are no global refrences to it that could be holding open the connection?

You MIGHT be able to use a proxy jni class that manages the loading and unloading for you, but that is idle specualtion.

i.e. implement the same interface and as part of each native source first checks if the DLL is loaded and if not load it. When you session is done ( or with a timier ) unload the .dll with part of the proxy class. The drawback is that you have 2 .dll''s one for the jni stub and the other .dll for the actual work. You also have to manage the .dll loading/unloading yourself.


Good luck

Share this post


Link to post
Share on other sites
You cannot unload DLLs.

However, if you need to do initialization every time it is loaded, why not just call some initialization routine in the DLL when you need it - to reinitialize its contents? There is no reason to put all initilization in DllMain(), besides maybe convenience.

Jacob Marner

Share this post


Link to post
Share on other sites

  • Advertisement