File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

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
Marshal

Joined: Jan 10, 2002
Posts: 60982
    
  65

"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] [Bear's FrontMan] [About Bear] [Books by Bear]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14103
    
  16

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 7 API documentation
Scala Notes - My blog about Scala
ravi khonal
Greenhorn

Joined: Jan 18, 2012
Posts: 1
check out this link guys,,

http://javarevisited.blogspot.com/2011/05/java-heap-space-memory-size-jvm.html
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: java.lang.OutOfMemoryError: Java heap space