Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase Heap size of JVM [duplicate]

Tags:

java

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) 
like image 242
Dhananjay Joshi Avatar asked Jun 23 '11 10:06

Dhananjay Joshi


People also ask

How do I increase allocated heap size?

1)Change the gradle. properties file and change the heap size as per your requirement. 2)"Edit Custom VM Options" from the Help menu. It will open studio.

How much heap size we can increase?

The theoretical limit is 2^64 bytes, which is 16 exabytes (1 exabyte = 1024 petabytes, 1 petabyte = 1024 terabytes). However, most OS's can't handle that. For instance, Linux can only support 64 terabytes of data.


2 Answers

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 
like image 53
oliholz Avatar answered Oct 03 '22 07:10

oliholz


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; 
like image 20
a-- Avatar answered Oct 03 '22 06:10

a--