Meaningless Drivel is fun!
The moose likes Java in General and the fly likes java.lang.OutOfMemoryError: Java heap space Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "java.lang.OutOfMemoryError: Java heap space" Watch "java.lang.OutOfMemoryError: Java heap space" New topic

java.lang.OutOfMemoryError: Java heap space

carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

Hi, i am creating an xlsx file with more that 100000 rows.

and i am gettign the error:

java.lang.OutOfMemoryError: Java heap space

i googled and found that the java heap size need to be increased, but I am confused either to increse it in Tomcat or eclipse or command line. As I am using these three in my project. Also i dont want to increase the heap for one specific application , as i have 2 more running .

Also please suggest me the commands to increse the heap size.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63868

"rocx sum", please check your private messages for an important administrative matter. Failure to do so will result in the removal of your account.

[Asking smart questions] [About Bear] [Books by Bear]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15094

If this is part of a web application, then you will need to change the memory settings in the Tomcat configuration. Lookup the documentation for your specific version of Tomcat to find out how to do that.

If it is part of a standalone Java application that you run from the command line, then you'd need to add a -Xmx option to the command. For example:

java -Xmx1024m org.mypackage.MyProgram

to give it a max of 1024 MB (1 GB) memory.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
ravi khonal

Joined: Jan 18, 2012
Posts: 1
check out this link guys,,
carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

I added a new environmental variable named JAVA_OPTS = -Xms1024m -Xmx1024m -XX:MaxPermSize=128m

Still i am getting the same error.

My tomcat is plugged into Eclipse and in eclipse.ini file i tried changing the -vmargs and gave -Xms1024m -Xmx1024m .
But Eclipse failed to start after this changes and i revert back the previous settings.
I agree. Here's the link:
subject: java.lang.OutOfMemoryError: Java heap space
It's not a secret anymore!