• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OutOfMemoryError client JMS

  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
i'm working with JMS. I did a simple class than send 500.000 messages to a queue.
After sending, i close the resouces. the problem is that when it send a message, increases memory space. When this has sent 14,500 messages throws an exception:
Exception in thread "Timer-0" java.lang.OutOfMemoryError: Java heap space
at java.nio.ByteBuffer.wrap(Unknown Source)
at java.lang.StringCoding$StringDecoder.decode(Unknown Source)
at java.lang.StringCoding.decode(Unknown Source)
at java.lang.String.<init>(Unknown Source)
this is the class:

http://pastebin.com/WZbz8VNN

thank you very much for the help
 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy!

I wonder why you perform all of the initial 'stuff' (performing JNDI lookup of the connection factory, queue, etc.) in the loop. It is not opptimal.

The second case is that such memory consumption can be a natural situation. You send a big bunch of messages so your heap can grow bigger. The most important thing here is to check if after the messages consumption the memory usage will drop down. If not - we may have some memory leak.

My recipe:
- please try to enlarge heap size. Try to set -Xmx=2048m.
 
reply
    Bookmark Topic Watch Topic
  • New Topic