Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to insert 2-milliion lines into a SQL Database, and get this error:

JDBC::error: Java heap space

The insert is a standart Mathematica SQL statement:

conn = myConn[ip]
columns = {"Col1", "Col2", "Col3", "Col4"}
SQLInsert[conn, "MyTable", columns,data]

Where data is a Listof 2-million elements (rows). The command works just fine for a smaller number of rows.

I know I could break data into small chunks, but I would like to know how to solve it increasing the Java heap space.

share|improve this question
Like this... ? – Oleksandr R. Dec 30 '13 at 1:11
@OleksandrR. interesting tks. Do you know how can I know my current heap space? – Murta Dec 30 '13 at 1:22
@Murta Yes, you can call JavaLink[] and then you see in my case -Xmx256m which defines the maximum possible. – halirutan Dec 30 '13 at 1:43
@halirutan strange, when I execute JavaLink[] I get: LinkObject['/Applications/‌​tents/MacOS/JavaApplicationStub' -init "/tmp/m000001265201",81,4] – Murta Dec 30 '13 at 2:10
Hm, on OSX, everything is different. I guess you have 256MB too. You could check the file FileNames["InstallJava.m", {$InstallationDirectory}, Infinity] and search for -Xmx. – halirutan Dec 30 '13 at 2:50
up vote 3 down vote accepted

You need to use JVMArguments

ReinstallJava[JVMArguments -> "-Xmx512m"]

Shameless copy From Wolfram ;-)

Or directly...

InstallJava[JVMArguments -> "-Xmx512m"]

The options available depend on your JVM runtime. The standard way to get the non-standard options is (in the shell) java -X

share|improve this answer
For Mac use: ReinstallJava[CommandLine->"java",JVMArguments->"-Xmx512m"]; – Murta Apr 30 '14 at 15:38
Nice link here – Murta Apr 30 '14 at 15:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.