Now, the problem is that the java classes persist even after being deleted from the matlab stack. I can call "clear java" and the variable containing the java class is deleted, but the class, and therefore the thread, persists in memory. I can tell because System.out.print will still display messages in MATLAB even after a "clear java" call. I notice significant performance losses after running simulations overnight because there are so many java classes in memory.
Is there any way to remove the java class instances from memory entirely?
Thanks!
Chris
to see what's still living in your ML cache, look at
[a,b,c]=inmem;
% and (most likely), you'll be surprised...
us
-Chris
hmm...
but do you really do this
import java.lang.*
System.out.print('foo');
% foo>>
clear java;
clear import; % <- !
System.out.print('foo')
% foo??? Undefined variable "System" or class "System.out.print".
us
OK, my machine throws te same error wth that code.
I tried "clear java;clear import" with my class instances, but it still doesn't kill the threads from memory. They're still printing to matlab. It's like the java classes can talk to me, but I can't talk to them.
-Chris
Warning: Duplicate entry,D:\[path]
>In javaclasspath>local_validate_dynamic_path at 276
In javaclasspath>local_javapath at 184
In javaclasspath at 119
[...]
Warning: Objects of [class] class exist - not clearing java
>In javaclasspath>local_javapath at 194
In javaclasspath at 119
[...]
I don't know if this is helpful or not...
-Chris
well... a slightly different problem...
% now, you must
clear 'your_class';
% as well
us
Hmm, nope. Clearing th java path does't help either. inmem still dos't repor it, but it's definitely still there.
-Chris
A simple example:
*******************************************
import utils.Extract;
dataMatrix = Extract.subsetArray(fileName, 010901,100601);
clear all
clear java
clear import
********************************************
Extract.subsetArray is a java method that returns a matrix of data from the file 'filename' between the dates 100901- 100601.
Nothing i do frees the memory, only restarting. I can't work around this as i need to put this in a loop.
Any further ideas?
Regards,
Mark
I also have a similar problem. I am running some simulations which use jPar to parallelise. I want to be able to run as many simulations as I like without having to restart MATLAB but I eat up the java memory running a sim and after a couple I will run out of memory.
I just want to be able to free this memory without having to restart MATLBA, but I cannot find anywhere how to do this?!
Any solutions?
Thanks
jPar authors fixed the memory leak in the java code... :)
Oh, very good! Do you know which version of MATLAB carries the fix?