5
$\begingroup$

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]
CloseSQLConnection[conn]

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.

$\endgroup$
6
  • $\begingroup$ Like this... support.wolfram.com/kb/3791 ? $\endgroup$ Commented Dec 30, 2013 at 1:11
  • $\begingroup$ @OleksandrR. interesting tks. Do you know how can I know my current heap space? $\endgroup$ Commented Dec 30, 2013 at 1:22
  • $\begingroup$ @Murta Yes, you can call JavaLink[] and then you see in my case -Xmx256m which defines the maximum possible. $\endgroup$ Commented Dec 30, 2013 at 1:43
  • $\begingroup$ @halirutan strange, when I execute JavaLink[] I get: LinkObject['/Applications/Mathematica.app/SystemFiles/Links/JLink/JLink.app/Contents/MacOS/JavaApplicationStub' -init "/tmp/m000001265201",81,4] $\endgroup$ Commented Dec 30, 2013 at 2:10
  • $\begingroup$ 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. $\endgroup$ Commented Dec 30, 2013 at 2:50

2 Answers 2

4
$\begingroup$

You need to use JVMArguments

<<JLink`;
InstallJava[];
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

$\endgroup$
2
  • 2
    $\begingroup$ For Mac use: ReinstallJava[CommandLine->"java",JVMArguments->"-Xmx512m"]; $\endgroup$ Commented Apr 30, 2014 at 15:38
  • $\begingroup$ Nice link here $\endgroup$ Commented Apr 30, 2014 at 15:46
0
$\begingroup$

2023 update on M1 Mac:

enter image description here

increase heap space to 1GB

<< JLink`;
InstallJava[];
ReinstallJava[JVMArguments -> "-Xmx1024m"]

increase it to 8GB

<< JLink`;
InstallJava[];
ReinstallJava[JVMArguments -> "-Xmx8192m"]
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.