フィルターのクリア

Should I call dispose on MWArray after I call getField in Java?

1 回表示 (過去 30 日間)
Yong
Yong 2013 年 8 月 26 日
I am using Java to call matlab. I figured out when I create a MWArray, I need to call dispose explicitly. Then I have this situation:
In the program I call a matlab method many times, every time it returns a MWStructArray m, then I call MWArray mw= m.getField(index) on the MWStructArray m, and print out mw. I will call dispose on m, My question is do I need call mw.dispose also?
A similar question is: I call a matlab method, it return a MWStructArray or MWCellArray m, this object is long live, i will keep it in the memory. But I will call MWArray mw= m.getField(index) many times, is safe to call mw.dispose() every time? will it destroy the data in m? Keep in mind, I want to reuse m again.
Is there any document on exactly how MCR keep/free the object.
Thanks
  1 件のコメント
Yong
Yong 2013 年 8 月 27 日
by looking the source code of MWStructArray.
public Object get(String paramString, int paramInt)
{
MWArray localMWArray = null;
try
{
localMWArray = getField(paramString, paramInt);
return localMWArray != null ? localMWArray.toArray() : null;
}
finally
{
if (localMWArray != null)
localMWArray.dispose();
}
}
It seems I should call dispose, and it is safe to do so.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeJava Package Integration についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by