56

I am getting the following error:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at SQLite.Vm.step(Native Method)
        at SQLite.Database.get_table(Database.java:314)
        at SQLite.JDBC2z.JDBCStatement.executeQuery(JDBCStatement.java:120)
        at SQLite.JDBC2z.JDBCStatement.executeQuery(JDBCStatement.java:168)
        at TestData.readData(TestData.java:21)
        at TestData.main(TestData.java:41)
Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
Dhananjay Joshi
  • 704
  • 1
  • 7
  • 8

6 Answers6

89

Following are few options available to change Heap Size.

-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size
-Xss<size>        set java thread stack size


java -Xmx256m TestData.java
oliholz
  • 7,447
  • 2
  • 43
  • 82
15

Java command line parameters

-Xms: initial heap size
-Xmx: Maximum heap size

if you are using Tomcat. Update CATALINA_OPTS environment variable

export CATALINA_OPTS=-Xms16m -Xmx256m;
Yi Jiang
  • 49,435
  • 16
  • 136
  • 136
a--
  • 753
  • 6
  • 15
13

Start the program with -Xms=[size] -Xmx -XX:MaxPermSize=[size] -XX:MaxNewSize=[size]

For example -

-Xms512m -Xmx1152m -XX:MaxPermSize=256m -XX:MaxNewSize=256m
spot35
  • 888
  • 4
  • 9
9

By using the -Xmx command line parameter when you invoke java.

See http://download.oracle.com/javase/6/docs/technotes/tools/windows/java.html

Philip Kirkbride
  • 21,381
  • 38
  • 125
  • 225
pap
  • 27,064
  • 6
  • 41
  • 46
8

Use -Xms1024m -Xmx1024m to control your heap size (1024m is only for demonstration, the exact number depends your system memory). Setting minimum and maximum heap size to the same is usually a best practice since JVM doesn't have to increase heap size at runtime.

michaelliu
  • 1,667
  • 2
  • 13
  • 13
2

-XmxSIZE

For example: -Xmx1024M

Nulldevice
  • 3,926
  • 3
  • 31
  • 37