Dear All,
I'm writing to share with the community the solution I've developed to solve the bothering OutOfMemory error that some times occurs when using PTB.
A short summary of the issue
After some (random) time Matlab crashes with the following exception:
This is due to some JVM classes (Swing related) generating a memory leak every time a display property is changed. These JVM classes are those responsible for displaying Matlab views (Command history, Current folder etc...).Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError:Java heap space.A solutionI wrote a Java piece of code that re-initializes these Java classes together with a Matlab command (jheapcl.m) acting as a wrapper. Calling this command will "really" clean up your heap memory, avoiding the infamous crash.You can find all the files on the Mathworks community here (http://www.mathworks.it/matlabcentral/fileexchange/36757-java-heap-cleaner).Currently it has been tested on Matlab 2011b and 2010b. Please comment/rate the file, letting me know if it really helps and if there are problems.Thank you very much in advance.D.