1

I have tried to create a small utility which reads excel and sends email. I am using ApachePOI library for that. When I executed the code from eclipse, initially I got java.lang.OutOfMemoryError: GC overhead limit exceeded error. Then I added -Xms1024m in the VM Arguments of eclipse and program worked fine in eclipse.

Then I exported the set of java programs and libraries into RunnableJar and bundled the dependent libraries.

Now from command line when i execute the command

java -Xms1024m -jar AutomateProcesses.jar

I am still getting the same error. I am not able to figure out the issue. could someone please help in this regard?

5
  • possible duplicate of GC overhead limit exceeded Commented Feb 27, 2013 at 13:03
  • You just posted the error and it seems like it is an problem with your garbage collection. Commented Feb 27, 2013 at 13:20
  • @dasKeks Could you please let me know how to solve the problem? Commented Feb 27, 2013 at 13:28
  • I could try if you post the whole error message. Commented Feb 27, 2013 at 15:43
  • java -Xms512m -Xmx2048 -jar AutomateProcesses.jar this works Commented Mar 1, 2013 at 14:31

3 Answers 3

1

You could try

java -Xms512m -Xmx2048 -jar AutomateProcesses.jar

If this is just whats going on in this VM which is what I expect. If the a library in the java process is then spawning a separate process then the library may need some other options to configure it.


EDIT:

An answer to this question points out that this error is because the GC is spending too much time trying to recover memory and not getting it. I am not very familiar with Appache POI but if it is talking to Excel from java then it is probably using COM calls into the Excel DLLs. It may be that there is a bug in the library or the way that you use it, leading to objects being locked out of garbage collection and thus the GC works very hard with little progress.

Can you try to isolate the code that has this problem into a smaller test case?

This post had a similar problem to such an extent that they re-wrote the way they were dealing with cells in Excel so as to avoid creating a large number of cellStyle objects.

In a similar vein, this person gave up and wrote their data to CSV format.

Sign up to request clarification or add additional context in comments.

5 Comments

I am getting this error in Linux terminal. but working fine in linux eclipse.
Are you running 64bit java? If so you could try upping the memory a lot and see if that works (assuming you have a fair bit of mem/vmem). It is a workaround not a fix.
yeah 64 bit java... could you please let me know whats upping the memory?
java -Xms512m -Xmx4096 -jar AutomateProcesses.jar
java -Xms512m -Xmx2048 -jar AutomateProcesses.jar this works :)
1

To set the maximum heap size and allow the Java VM to allocate more memory, you have to use the command -Xmx1024M (or -Xmx1G).

-Xms sets the minimum respectively the initial heap size.

1 Comment

I just figured out that -Xms should also work. So my answer is porbably not the solution.
0

java.lang.OutOfMemoryError: GC overhead limit exceeded is a symptom of a problem with the JVM garbage collection (too much time spent in GC). The error is actually preventing the whole JVM to go in hang state so you can gather some extra stats.

Reading an Excel Sheet can be memory intensive depending how large the file is which will add pressure point to the GC process.

Enabling and analyzing verbose:gc will definitely help. You could also generate a JVM Heap Dump and determine where that memory is retained in your Java utility program. You will have to either adjust the Java heap size and / or resolve any faulty memory retention.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.