Increasing the Java heap space allows J/Link to use more memory. This helps J/Link when it requires more memory than it can normally access. To increase the Java heap space in Mathematica, restart the Java Virtual Machine with a special argument.

Open Mathematica and run:

ReinstallJava[JVMArguments -> "-Xmx512m"]

Here, “512m” stands for 512 megabytes, or 0.5GB. To further increase the Java Heap Space, use, for example, “1024m” for 1GB.

Whenever you restart Mathematica or start a new kernel, this code needs to be evaluated for J/Link to have access to the additional heap space.

To have the code automatically evaluate when you start Mathematica, place the code in Mathematica’s init.m file.