Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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 Commento
Yong
Yong il 27 Ago 2013
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.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Java Package Integration in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by