Alex
Alex

Reputation: 1486

java.lang.OutOfMemoryError: Java heap space in every 2-3 Hours

In our application we have both, Apache Server (for the front end only) & JBoss 4.2 (for the business / backend end). We are using Ubuntu 12 as server OS. Our application is throwing java.lang.OutOfMemoryError: "Java heap space" repeatedly. (It throws OOMEs for an hour or so and then goes back to working normally for next 2-3 hours. Then it repeats the pattern.) Our Java memory settings are

-Xms512m -Xmx1024m

Our server has 6 GB of Ram physically. Please guide us do we need to increase java Heap size. If yes, what should be the ideal size considering physical 6GB of Ram.

Upvotes: 0

Views: 752

Answers (2)

Peter Lawrey
Peter Lawrey

Reputation: 533432

I would check whether you have a memory leak e.g. are there objects building up and not being freed.

You can do that with a profiler e.g. visualvm or jmap -histo:live might be enough.

If you don't have a memory leak and the memory usage is valid I would try increasing the maximum to the maximum amount of memory you would want the JVM to use e.g perhaps 4 GB.

Upvotes: 1

Dev
Dev

Reputation: 6776

Are you sure you dont have memory leaks? Also if you are using high memory using api like POI for doc or itext for PDF the you are utilizing code to keep memory footprint low. You can use a profiler to see what exactly is happening. If you still need to increase increase step by step till it gets to a appropriate value.

like

-Xms512m -Xmx1024m

then

-Xms512m -Xmx2048m

so on ...

Upvotes: 1

Related Questions