tomcat服務啟動后,通過 jna 呼叫dll后,如何釋放已呼叫DLL;代碼中如何寫?
uj5u.com熱心網友回復:
如今大神都不逛CSDN了么uj5u.com熱心網友回復:
我也遇到一樣的問題,似乎沒有看的JNA 有直接釋放的APIuj5u.com熱心網友回復:
NativeLibrary instance = NativeLibrary.getInstance(StaticConstant.EDI_MIDDLEWARE_DLL);instance.getFunction("initial_DM").invoke(new Object[]{});
instance.getFunction("gen_edi2carrier").invokeDouble(new Object[]{java,jobD});
instance.dispose();
uj5u.com熱心網友回復:
這種問題自己查一下官方檔案https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/invocation.html#JNI_OnUnload
摘自官方檔案
The VM calls JNI_OnUnload when the class loader containing the native library is garbage collected.
也就是說不用你手動釋放,當加載dll的類的類加載器被垃圾回收時就會自動釋放。
所以,想手動釋放,那就自己釋放類加載器
參考以下鏈接的例子
https://web.archive.org/web/20140704120535/http://www.codethesis.com/blog/unload-java-jni-dll
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/112026.html
標籤:Web 開發
上一篇:秒殺java人員神器
