Monday, November 14, 2011

Matlab Java space heap memory size problem solution

The solution is very simple
1- check what you have

2- To check the version of your Java, type the following in the Matlab prompt window:
version -java
3- to check the current size you have type:
java.lang.Runtime.getRuntime.maxMemory
java.lang.Runtime.getRuntime.totalMemory
java.lang.Runtime.getRuntime.freeMemory


To Solve it:
4-open a text file
5- write the following in it
For JVM of 1.2.2 and later, place the following in your java.opts file:
-Xmx256m

For JVM 1.1.8 'java.opts', place the following in your java.opts file:
-mx256m


6- Save the file with the following name:

java.opts


7- you can simply put a number more than 256 if your machine allow it for example (Xms512m)
8- Save the file in the matlab path directory
Simply will work :)

some people increase it from the cmd for dos like this,

    java -Xms64m -Xmx256m

I am not sure if this works, but the method I just described works for sure :)

Modifications to Run Matlab exe files for Windows 7

1- Open the system properties
2- go to "Advanced"
3- click on "Environment Variables"
4- go to "User variables for ...."
5- Click on "New"
6- for variable name:
PATH
7- for Variable value:
set PATH=C:\Program Files\MATLAB\MATLAB Compiler Runtime\v713\runtime\win32;

which is the location of the matlab runtime compiler, which you need to change according to your files location