JACOB不正确释放对象

编程入门 行业动态 更新时间:2024-10-26 22:20:34
本文介绍了JACOB不正确释放对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个eclipse插件,它使用Jacob连接到一个COM组件。但是在我完全关闭插件后,.exe文件停留在Windows进程中。

我使用 ComThread.InitMTA c $ c>用于初始化,并确保在关闭应用程序之前为每个创建的COM对象调用 SafeRelease(),并调用 ComThread.Release

解决方案

与TD2JIRA转换器有相同的问题。最终不得不修补一个Jacob文件释放对象。之后,一切顺利。

我的客户端logout()方法中的代码现在如下所示:

try { Class rot = ROT.class; 方法clear = rot.getDeclaredMethod(clearObjects,new Class [] {}); clear.setAccessible(true); clear.invoke(null,new Object [] {}); } catch(Exception ex){ ex.printStackTrace(); }

ROT类最初无法访问,AFAIR。

更新

在Jacob发布资源的正确方法是调用

ComThread.InitSTA(); //或ComThread.InitMTA() ... ComThread.Release();

不好的是,有时它不会帮助。尽管Jacob调用本地方法release(),内存(甚至Java内存,但JVM进程内存)不可控制地增长。

I have an eclipse plugin, which connects to a COM component using Jacob. But after I close the plugin entirely, the .exe file stays hanging in Windows processes.

I use ComThread.InitMTA(true) for initialization and make sure that SafeRelease() is called for every COM object I created before closing the app and I call ComThread.Release() at the very end.

Do I leave something undone?

解决方案

Had the same problem with TD2JIRA converter. Eventually had to patch one of the Jacob files to release the objects. After that all went smooth.

The code in my client logout() method now looks like this:

try { Class rot = ROT.class; Method clear = rot.getDeclaredMethod("clearObjects", new Class[]{}); clear.setAccessible(true); clear.invoke(null, new Object[]{}); } catch( Exception ex ) { ex.printStackTrace(); }

The ROT class wasn't accessible initially, AFAIR.

Update

The correct way to release resources in Jacob is to call

ComThread.InitSTA(); // or ComThread.InitMTA() ... ComThread.Release();

Bad thing though is that sometimes it doesn't help. Despite Jacob calls native method release(), the memory (not even Java memory, but JVM process memory) grows uncontrollably.

更多推荐

JACOB不正确释放对象

本文发布于:2023-11-09 15:16:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572705.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不正确   对象   JACOB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!