1

I created dynamic web project in eclipse(Kepler).In my application, I used Spring,Hibernate, JSF,JMS & Quartz sheduler. What I wanted to do is, I want to run a shedule to send database values to ActiveMQ & listen by implementing MessageListener. My app shedule to send values every 5 seconds & it works fine. But after sending 15500 messages to the ActiveMQ, It raised following error. Any reason why this can happen?

Exception in thread "ActiveMQ InactivityMonitor Worker" java.lang.OutOfMemoryError: Java heap space
at java.lang.AbstractStringBuilder.<init>(Unknown Source)
at java.lang.StringBuffer.<init>(Unknown Source)
at org.slf4j.helpers.MessageFormatter.arrayFormat(MessageFormatter.java:194)
at org.slf4j.helpers.MessageFormatter.format(MessageFormatter.java:124)
at org.slf4j.impl.Log4jLoggerAdapter.debug(Log4jLoggerAdapter.java:228)
at org.apache.activemq.transport.AbstractInactivityMonitor$3.run(AbstractInactivityMonitor.java:161)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Exception in thread:

"org.springframework.jms.listener.DefaultMessageListenerContainer#0-2" java.lang.OutOfMemoryError: Java heap space Exception in thread "DefaultQuartzScheduler_QuartzSchedulerThread" java.lang.OutOfMemoryError: Java heap space

Insane Skull
  • 9,220
  • 9
  • 44
  • 63
chk.buddi
  • 554
  • 1
  • 8
  • 29
  • Use a profiling tool like [YourKit](https://www.yourkit.com/) to identify what part of the code uses your memory and fix it. – shan1024 Sep 10 '15 at 05:10

1 Answers1

0

Make sure your code doesn't cause memory leaks. For example, open resources should be closed after usage.

You can use profiling tools like visualvm (bundled with JDK) and Yourkit (commercial) to identify memory issues.

You can also try to increase Java heap size:

-Xms<size>        initial Java heap size
-Xmx<size>        maximum Java heap size

For example:

java -Xms512m -Xmx2g
Amila
  • 5,195
  • 1
  • 27
  • 46