清除Java内存 [英] clear Java memory

查看:308
本文介绍了清除Java内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Matlab 2012b连接到我导入数据的另一个程序(Imaris)。通信实际上是通过java作为接口发生的。我遇到的问题是数据不会从Java内存中删除并随着时间的推移而堆积起来,直到Matlab最终崩溃。
clear Java不起作用并产生以下警告:Ice / ConnectionRefusedException类的对象存在 - 不清除

I am using Matlab 2012b to connect to another program (Imaris) from which I import data. The communication actually happens via java as interface. The problem I have is that the data is not deleted from the Java memory and piles up over time until Matlab ultimately crashes. "clear Java" does not work and produces the following warning: "Objects of Ice/ConnectionRefusedException class exist - not clearing"

我发现的唯一解决方案真的很清楚Java内存是重新启动Matlab,在我的情况下这不是一个选项。

The only solution I found to really clear the Java memory is to restart Matlab, which is not an option in my case.

在网上搜索时我发现很多人都是这样做的问题。 ( http://www.mathworks.de/matlabcentral/newsreader/view_thread/283708

When searching through the web I found that quite a few people have encoutered the same problem. (http://www.mathworks.de/matlabcentral/newsreader/view_thread/283708)

但是我找不到如何解决问题的答案。有没有人知道一个解决方案?

However I did not find an answer how to solve the issue. Does anybody know a solution?

推荐答案

如果你从clear java收到消息,那就是存在一个类的对象,并且清除所有不是删除它们,然后某处某处有对象的引用。这通常发生在回调,监听器等,或者当您将对象的引用添加到匿名函数句柄等中时。

if you are getting messages back from clear java that there are objects of a class that exist, and clear all isn't removing them, then something somewhere has a reference to the object. this can often happen with callbacks, listeners etc, or when you add a reference to an object into an anonymous function handle or the like.

clear命令删除对来自工作空间的对象,但由于回调中存在匿名(或其他)引用,因此对象不能被垃圾收集,因此保留在内存中(并且可能是孤立的)

the clear commands remove the reference to the object from the workspace(s), but as the anonymous (or otherwise) reference exists in a callback the object can't be garbage collected so remains in memory (and potentially orphaned)

当我懒得写出好的析构函数时,我看到了很多东西

i see this a lot when i am lazy about writing good destructors

这篇关于清除Java内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆