[jboss-user] [JBoss Messaging] - Re: OutOfMemoryError with JBoss Messaging

harish43 do-not-reply at jboss.com
Mon May 5 15:26:10 EDT 2008


Andy,

Sorry for the delay in responding to your request. I have a simple testcase to reproduce the issue.

I have run two tests with the queue example that comes with the JBoss Messaging distribution. The first test was to use the queue example to connect to a JBoss Messaging instance and the second test was to use the same queue example to connect to a JBossMQ instance. I used version 1.4.1.Beta1 of JBM in and version 4.0 of JBossMQ. The JBoss server version is 4.2.2.GA.

I enhanced the queue example to do the following steps 1 million times.

1. Lookup /ConnectionFactory
2. Lookup Queue
3. Create Connection
4. Create Session
5. Create Producer
6. Create Text Message
7. Send message
8. Create Consumer
9. Start the connection
10. Receive text message
11. Close connection

The JBossMQ test was twice as fast and consumed less memory overall. I had given 1GB for Eden and 1GB for old generation and the JBossMQ test used less than 80 MB of old generation throughout the test. I didn't see any of the MQ or remoting classes grow in number or size throughput the test.

In the JBM test the memory usage grew gradually over time and it used more than 400MB. I noticed the following classes grew.

At the beginning of the test

           

680 ..... 49k ..... org.jboss.remoting.transport.bisocket.BisocketClientInvoker$PingTimerTask (CL #4)
680 ..... 5k ...... org.jboss.remoting.transport.bisocket.BisocketClientInvoker$BooleanHolder (CL #4)
7 ....... 8k ...... java.util.TimerTask[]


At the end of the test

        

689030 .. 49793k .. org.jboss.remoting.transport.bisocket.BisocketClientInvoker$PingTimerTask (CL #4)
689030 .. 6055k ... org.jboss.remoting.transport.bisocket.BisocketClientInvoker$BooleanHolder (CL #4)
7 ....... 4102k ... java.util.TimerTask[]

The destinations-service.xml file is as below:

<?xml version="1.0" encoding="UTF-8"?>

<!--
     Messaging Destinations deployment descriptor.

     $Id: destinations-service.xml 1930 2007-01-09 18:16:04Z timfox $
 -->


  
   <!--
      The Default Dead Letter Queue. This destination is a dependency of an EJB MDB container.
   -->

   <mbean code="org.jboss.jms.server.destination.QueueService"
      name="jboss.messaging.destination:service=Queue,name=DLQ"
      xmbean-dd="xmdesc/Queue-xmbean.xml">
      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer
      jboss.messaging:service=PostOffice
   

   <!--
      The Default Expiry Queue.
   -->

   <mbean code="org.jboss.jms.server.destination.QueueService"
      name="jboss.messaging.destination:service=Queue,name=ExpiryQueue"
      xmbean-dd="xmdesc/Queue-xmbean.xml">
      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer
      jboss.messaging:service=PostOffice
   

   <mbean code="org.jboss.jms.server.destination.QueueService"
      name="jboss.messaging.destination:service=Queue,name=testQueue"
      xmbean-dd="xmdesc/Queue-xmbean.xml">
      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer
      jboss.messaging:service=PostOffice
   



The connection-factories-service.xml file is as below:

<?xml version="1.0" encoding="UTF-8"?>

<!--
     Messaging Connection Factories deployment descriptor.

     $Id: connection-factories-service.xml 3332 2007-11-15 09:32:43Z timfox $
 -->



   <!-- The default connection factory does not support automatic failover or load balancing-
        this is so we can maintain compatiblity with applications written for JBoss MQ which use this
        connection factory.
   -->     
   <mbean code="org.jboss.jms.server.connectionfactory.ConnectionFactory"
      name="jboss.messaging.connectionfactory:service=ConnectionFactory"
      xmbean-dd="xmdesc/ConnectionFactory-xmbean.xml">
      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer
      <depends optional-attribute-name="Connector">jboss.messaging:service=Connector,transport=bisocket
      jboss.messaging:service=PostOffice

      
         
	    /ConnectionFactory
            /XAConnectionFactory
            java:/ConnectionFactory
            java:/XAConnectionFactory
         
      
   



I haven't modified the remoting-bisocket-service.xml and the messaging-service.xml files and the only change I made to the mysql-persistence-service.xml file is to set the Clustered attribute of the Post Office to false.

The modified queue example is below:
package org.jboss.example.jms.queue;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;

import org.jboss.example.jms.common.ExampleSupport;

/**
 * This example creates a JMS Connection to a JBoss Messaging instance and uses it to create a
 * session and a message producer, which sends a message to the queue "queue/testQueue".  Then, the
 * example uses the same connection to create a consumer that that reads a single message from the
 * queue. The example is considered successful if the message consumer receives without any error
 * the message that was sent by the producer.
 *
 * Since this example is also used by the smoke test, it is essential that the VM exits with exit
 * code 0 in case of successful execution and a non-zero value on failure.
 *
 * @author Ovidiu Feodorov
 * @author Luc Texier
 * @author Tim Fox
 * @version $Revision: 2868 $
 *
 * $Id: QueueExample.java 2868 2007-07-10 20:22:16Z timfox $
 */
public class QueueExample extends ExampleSupport
{

   public void example() throws Exception
   {
      String destinationName = getDestinationJNDIName();

      InitialContext ic = null;
      ConnectionFactory cf = null;
      Connection connection =  null;

      try
      {
         for(long i = 0; i < 1000000; i++) {
         ic = new InitialContext();

         cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
         Queue queue = (Queue)ic.lookup(destinationName);
         log("Queue " + destinationName + " exists");

         connection = cf.createConnection();
         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageProducer sender = session.createProducer(queue);

         TextMessage message = session.createTextMessage("Hello!");
         sender.send(message);
         log("Message #" + i);
         log("The message was successfully sent to the " + queue.getQueueName() + " queue");
         MessageConsumer consumer =  session.createConsumer(queue);

         connection.start();

         message = (TextMessage)consumer.receive();

         log("Received message: " + message.getText());
         assertEquals("Hello!", message.getText());

         displayProviderInfo(connection.getMetaData());
         closeConnection(connection);
        }
      }
      finally
      {
         if(ic != null)
         {
            try
            {
               ic.close();
            }
            catch(Exception e)
            {
               throw e;
            }
         }

         // ALWAYS close your connection in a finally block to avoid leaks.
         // Closing connection also takes care of closing its related objects e.g. sessions.
         closeConnection(connection);
      }
   }

   private void closeConnection(Connection con)
   {
      try
      {
         if (con != null)
         {
            con.close();
         }
      }
      catch(JMSException jmse)
      {
         log("Could not close connection " + con +" exception was " + jmse);
      }
   }

   protected boolean isQueueExample()
   {
      return true;
   }

   public static void main(String[] args)
   {
      new QueueExample().run();
   }

}

I have also tried with moving the two lookups to outside of the for loop with similar results.

The question I have is why are the org.jboss.remoting.transport.bisocket.BisocketClientInvoker$PingTimerTask and the org.jboss.remoting.transport.bisocket.BisocketClientInvoker$BooleanHolder classes are growing over time?

Please let me know if you need any more information.

Harish.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4148677#4148677

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4148677



More information about the jboss-user mailing list