Monday, June 9, 2008

Out of Memory issue in Weblogic

Its one of the scary part i came across when the clients came across with out of memory error. The application was pushing around 40,000 messages to the queue and all the messages have been holded in the memory and finalyy ended up with Out of Memory exception.

There are WebLogic settings that take care of this issue. You can set the server to only load up the first N number of messages or X number of bytes to avoid OOM issues. These can be set up by going to the JMSServer config -> Thresholds and Quotas and configure bytes paging or message paging (or both).

Recommendation:
Set Bytes Threshold High to 1048576, set Bytes Threshold Low to 524288, and set Bytes Paging Enabled to true. Set Messages Threshold High to 1000, set Messsages Threshold Low to 500 and set Messages Paging Enabled
to true. This will ensure there is never more than 1 GB and no more than 1000 JMS messages in RAM.

Few forums that would help :
http://forums.bea.com/thread.jspa?threadID=570000795


Few reasons why OutOfMemory error could occur and their related solution.

1. When the producers are faster than consumers.

  • Quotas can be used to help this situation. Your sender will then receive ResourceAllocationExceptions and the server will stay up.

2. Cache-related OutOfMemoryErrors.

3. Handling the
OutOfMemoryErrors.
  • Message quotas prevent a WebLogic JMS server from filling up with messages and possibly running out of memory, causing unexpected results. Unless the "Blocking Sends" feature has been implemented, when you reach your quota, JMS prevents further sends with a ResourceAllocationException (rather than blocking). You can set quotas on individual destinations or on a server as a whole.
  • The thresholds are not flow control - though they would be better suited to that application than the quotas. The thresholds are simply settings that when exceeded cause a message to be logged to the console to let you know that you are falling behind.
  • WebLogic JMS also has a flow control feature that enables a JMS server or destination to slow down message producers when it is becoming overloaded. Specifically, when a JMS server/destination exceeds its specified bytes or messages thresholds, it instructs producers to limit their message flow.
  • Ref : http://edocs.bea.com/wls/docs81/faq/jms.html#260519