activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From HU <gong...@hotmail.com>
Subject Re: Broker used up the memory
Date Thu, 28 Sep 2006 04:28:59 GMT

Hi, James.

The OutOfMemory error on consumer thread side occurred too.
It seems occurred on where send a respond message by consumer thread.
[Thread-1265](Interrupting...(Exception OutOfMemoryError))
   ActiveMQMapMessage.toString() line:661
   String.valueOf(Object) line: unusable
   StringBuffer.append(Object) line: unusable
   ActiveMQSession.send(ActiveMQMessageProducer,....
   ActiveMQMessageProducer.send(destination,Message,int,int,long) line:462
   ActiveMQMessageProducer.send(Message) line:356
   Mewconsumer.run() line:154
.....
 


HU wrote:
> 
> Hi, James.
> 
> Our system have to continue to keep the running  one  month or more long
> term without any memory leaks.
> 
> Yesterday's test was interrupted due to the memory leak(OutOfMemory) on
> the consumer thread side after I changed the java heap to -Xmx512K.
> 
> Now I began a new test following the prefetch limit.
> I changed the code:
> destinetionQueue = session.createQueue("RequestQueue");
> to
> destinetionQueue = New
> ActiveMQQueue("RequestQueue?consumer.prefetchSize=1");
> .
> The test is running now, but the GC tell me the heap is used slowing up...
> 
> 
> 
> James.Strachan wrote:
>> 
>> A consumer will use a readonable amount of RAM due to the prefetch
>> bufffer...
>> 
>> http://incubator.apache.org/activemq/what-is-the-prefetch-limit-for.html
>> 
>> if you are worried about RAM usage for a consumer, set the prefetch to 1
>> 
>> On 9/27/06, HU <gong_pu@hotmail.com> wrote:
>>>
>>>
>>> OK, I will let it run to dead.
>>>
>>> It has already run about 7Hours and send 7300 messages between Sender
>>> and
>>> consumer.
>>> Now, It is still running..
>>> The used heap by Consumer is up to 2.5M by GC.
>>>
>>>
>>> James.Strachan wrote:
>>> >
>>> > How long do you run your system for? Try send about 10,000 messages
>>> > through the system, then monitor the memory and see if there's a leak.
>>> >
>>> > On 9/27/06, HU <gong_pu@hotmail.com> wrote:
>>> >>
>>> >> Hi, James.
>>> >>
>>> >> Thanks, I have had the broker run with Mysql DB.
>>> >>
>>> >> Then I run the broker and a sender on a PC and run a consumer on
>>> another
>>> >> PC,
>>> >> Send a message to a queue by the sender thread and receve the
>>> messsage by
>>> >> the consumer thread then reply a message to sender thread by the
>>> >> consumer,
>>> >> repeat the actions.
>>> >> I found the heap was used creep up and did not found the used memory
>>> be
>>> >> released by the consumer thread. I used GC to get tracing for the
>>> test.
>>> >> Following are the codes of my test, could you please help me to fix
>>> the
>>> >> issue.
>>> >>
>>> >> public class Newconsumer extends Thread{
>>> >>     private Session         session;
>>> >>     private Connection      connection;
>>> >>     private MessageConsumer consumer;
>>> >>     private Destination     destinetionQueue;
>>> >>     public Newconsumer(Connection con) {
>>> >>         this.connection = con;
>>> >>         try {
>>> >>             session = this.connection.createSession(true,
>>> >> Session.AUTO_ACKNOWLEDGE);
>>> >>             destinetionQueue = session.createQueue("RequestQueue");
>>> >>             consumer = session.createConsumer(destinetionQueue);
>>> >>         } catch (JMSException e) { }
>>> >>     }
>>> >>
>>> >>     public void close() {
>>> >>         try {
>>> >>                 if( consumer != null ) consumer.close();
>>> >>             if (session != null) session.close();
>>> >>         } catch (JMSException e) {  e.printStackTrace(); }
>>> >>     }
>>> >>
>>> >>     public void run() {
>>> >>         while(true){
>>> >>             try {
>>> >>                 Message msg = consumer.receive(10000);
>>> >>                 if ( msg == null ) continue;
>>> >>                 Destination destResp = ((MapMessage)
>>> msg).getJMSReplyTo()
>>> >> ;
>>> >>                 String sCorrelationID = ((MapMessage)
>>> >> msg).getJMSCorrelationID();
>>> >>                 String sAnkenID = ((MapMessage) msg).getString("ID");
>>> >>                 Session sessSend = this.connection.createSession(
>>> false,
>>> >> Session.AUTO_ACKNOWLEDGE);
>>> >>                 MapMessage msgTime = sessSend.createMapMessage();
>>> >>                 msgTime.setJMSCorrelationID( sCorrelationID);
>>> >>                 msgTime.setString( "ID",sAnkenID);
>>> >>                 msgTime.setLong("TIMEOUT",35000 );
>>> >>                 MessageProducer producer =
>>> >> sessSend.createProducer(destResp);
>>> >>                 producer.send(msgTime);
>>> >>                 MapMessage msgRes = session.createMapMessage();
>>> >>                 msgRes.setJMSCorrelationID( sCorrelationID);
>>> >>                 msgRes.setString( "ID",sAnkenID);
>>> >>                 msgRes.setString( "RESULT","SUCCESS");
>>> >>                 producer.send(msgRes);
>>> >>                 this.session.commit();
>>> >>                 producer.close();
>>> >>                 producer=null;
>>> >>                 sessSend.close();
>>> >>                 sessSend=null;
>>> >>
>>> >>             } catch (JMSException e) { e.printStackTrace(); }
>>> >>             break;
>>> >>         }
>>> >>         this.close();
>>> >>     }
>>> >> }
>>> >>
>>> >> public class ConsumerController {
>>> >>         public static Newconsumer consumer;
>>> >>
>>> >>     public static void main(String[] args) throws NamingException {
>>> >>         ActiveMQConnectionFactory factory;
>>> >>         Connection                connAnken;
>>> >>         factory = new
>>> ActiveMQConnectionFactory("tcp://localhost:61616");
>>> >>         try {
>>> >>             connAnken = factory.createQueueConnection();
>>> >>             connAnken.start();
>>> >>             consumer = new Newconsumer(connAnken);
>>> >>                 consumer.start() ;
>>> >>             try {
>>> >>                      while(true) {
>>> >>                          consumer.join();
>>> >>                          consumer =null;
>>> >>                          consumer = new Newconsumer(connAnken);
>>> >>                          consumer.start();
>>> >>                      }
>>> >>             } catch (Throwable e) {
>>> >>                 e.printStackTrace();
>>> >>             } finally{
>>> >>                 connAnken.close() ;
>>> >>                 connAnken=null;
>>> >>             }
>>> >>         } catch (Throwable e) { e.printStackTrace(); }
>>> >>     }
>>> >> }
>>> >>
>>> >>
>>> >> activemq.xml
>>> >>
>>> ------------------------------------------------------------------------------------------
>>> >> <!-- START SNIPPET: example -->
>>> >> <beans xmlns="http://activemq.org/config/1.0">
>>> >>   <bean
>>> >>
>>> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
>>> >>   <broker useJmx="true">
>>> >>     <destinationPolicy>
>>> >>       <policyMap><policyEntries>
>>> >>           <policyEntry topic="FOO.>">
>>> >>             <dispatchPolicy>
>>> >>               <strictOrderDispatchPolicy />
>>> >>             </dispatchPolicy>
>>> >>             <subscriptionRecoveryPolicy>
>>> >>               <lastImageSubscriptionRecoveryPolicy />
>>> >>             </subscriptionRecoveryPolicy>
>>> >>           </policyEntry>
>>> >>       </policyEntries></policyMap>
>>> >>     </destinationPolicy>
>>> >>     <persistenceAdapter>
>>> >>       <journaledJDBC journalLogFiles="5"
>>> >> dataDirectory="../activemq-data-0926" dataSource="#mysql-ds"/>
>>> >>     </persistenceAdapter>
>>> >>     <transportConnectors>
>>> >>        <transportConnector name="default" uri="tcp://localhost:61616"
>>> >> discoveryUri="multicast://default"/>
>>> >>        <transportConnector name="stomp"  
>>> uri="stomp://localhost:61613"/>
>>> >>     </transportConnectors>
>>> >>     <networkConnectors>
>>> >>       <networkConnector name="default" uri="multicast://default"/>
>>> >>     </networkConnectors>
>>> >>   </broker>
>>> >>   <bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource"
>>> >> destroy-method="close">
>>> >>     <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
>>> >>     <property name="url"
>>> >> value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true"/>
>>> >>     <property name="username" value="activemq"/>
>>> >>     <property name="password" value="activemq"/>
>>> >>     <property name="poolPreparedStatements" value="true"/>
>>> >>   </bean>
>>> >>
>>> >> </beans>
>>> >> <!-- END SNIPPET: example -->
>>> >>
>>> >> eclipse.ini
>>> >>
>>> ------------------------------------------------------------------------------------------
>>> >> -vmargs
>>> >> -Xms128M
>>> >> -Xmx512M
>>> >> -XX:PermSize=64M
>>> >> -XX:MaxPermSize=128M
>>> >>
>>> >> Thanks,
>>> >> Hu
>>> >> --
>>> >> View this message in context:
>>> >>
>>> http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6523894
>>> >> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>> >>
>>> >>
>>> >
>>> >
>>> > --
>>> >
>>> > James
>>> > -------
>>> > http://radio.weblogs.com/0112098/
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6524501
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
>>>
>> 
>> 
>> -- 
>> 
>> James
>> -------
>> http://radio.weblogs.com/0112098/
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6540031
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message