0

We have created Spring Listener/Consumer receives the messages form ActiveMQ and store it in RDBMS.This application runs continuously.we used ExecutorService for Listener to receive messages.Its threadpoolsize=15. If the application runs more than hours it stops with out of memory error.

  1. Someone please help to find the reason for this error.
  2. How the GC works with executorService,Since the service shutdown only when the application stops.
byxor
  • 5,930
  • 4
  • 27
  • 44
S RB
  • 41
  • 6

1 Answers1

1

You have a memory leak in your application or you are accumulating objects which should be garbage collected. You should use software like JProfiler to locate the cause.

You can also increase the RAM available to the JVM but it's only a temporary solution if you don't fix the leak

How the GC works with executorService,Since the service shutdown only when the application stops.

The error is telling you that it can't create a new thread because there isn't enough memory.

klonq
  • 3,535
  • 4
  • 36
  • 58
  • 1
    Whoever downvoted this should explain why. The term memory leak may not apply the same as in languages like C/C++ but the rationale is the same. The OP is creating data making reachable likely by the threads in the ExecutorService and not allowing Java to reclaim it. Causing the GC to thrash and resulting in the OOM error. – John Vint Dec 18 '19 at 12:55
  • One comment `The error is telling you that it can't create a new thread because there isn't enough memory.` Is not exactly true. The application completes because when the thread stops the reachable data from those threads are no longer reachable and can be reclaimed by the VM – John Vint Dec 18 '19 at 12:58