You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by HU <go...@hotmail.com> on 2006/09/22 12:14:48 UTC

Broker used up the memory

I did a test as below:
1, use below codes to start a broker thread that only create 2 queues:

BrokerService broker = new BrokerService();
broker.addConnector("tcp://localhost:61616");
broker.start();
ActiveMQConnectionFactory connectionFactory;
connectionFactory = new ActiveMQConnectionFactory(
"failover:tcp://localhost:61616");

2, create a sender thread and  a consumer thread which use the 2 queues.
3, Send a mesesage from sender thread through a queue then receive the
message on the consumer thread.
4, Send a message from consumer thread through another queue and recieve the
message on the sender thread.
5, repeat 3 and 4.

After send about 380 messages from sendder thread, an error occurred on the
broker thread which is:
Thread[ActiveMQ Transport server: tcp//XXX:61616]( Interrupting...
(Exception OutOfMemoryError)
 OpenWireFormat.<int>(int) Line:62
....

Could someone tell me please how to resolve the problem.
-- 
View this message in context: http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6444443
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Broker used up the memory

Posted by HU <go...@hotmail.com>.
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 <go...@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 <go...@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.


Re: Broker used up the memory

Posted by James Strachan <ja...@gmail.com>.
On 10/2/06, Hiroshi Ayukawa <ay...@gmail.com> wrote:
>
> Hi, all.
>
> org.apache.activemq.command.ActiveMQObjectMessage#storeContent() is supposed
> to be buggy.

No its not :)


> ObjectOutputStream should be reset as well as other parts of acticemq do.
> ----------------------------------- Line 98--100 should be..
> --------------------------------------------------------------
>                 ObjectOutputStream objOut = new ObjectOutputStream(dataOut);
>                 objOut.writeObject(object);
> +              objOut.flush();
> +              objOut.reset();
>                 objOut.close();

Thanks for the patch! - I've applied to to trunk. There are only 2
other uses of ObjectOutputStream in the entire codebase both of which
were calling these two methods, so I think you found be bad useage :)

Hu - I wonder could you try your tests again with the trunk code and
see if this fixes your memory leak?

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Don't need a journal for the BrokerService

Posted by James Strachan <ja...@gmail.com>.
On 10/4/06, Pico Florin <pi...@yahoo.co.uk> wrote:
> Hi!
>    Can you send me the exactly code that you  wrote in the  xml-file where you set up this funxtionality? Also, I would like to  know if it is possible to set up this configuration programatically not  in a configuration file.

Yes - just use the BrokerService bean.
http://incubator.apache.org/activemq/how-do-i-embed-a-broker-inside-a-connection.html

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Don't need a journal for the BrokerService

Posted by HU <go...@hotmail.com>.
The activemq.xml that I am using shown as below:

<!-- START SNIPPET: example -->
<beans xmlns="http://activemq.org/config/1.0">
  <!-- Allows us to use system properties as variables in this configuration
file -->
  <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
  <broker useJmx="true">
    <!-- In ActiveMQ 4, you can setup destination policies -->
    <destinationPolicy>
      <policyMap><policyEntries>
          <policyEntry topic="FOO.>">
            <dispatchPolicy>
              <strictOrderDispatchPolicy />
            </dispatchPolicy>
            <subscriptionRecoveryPolicy>
              <lastImageSubscriptionRecoveryPolicy />
            </subscriptionRecoveryPolicy>
          </policyEntry>

      </policyEntries></policyMap>
    </destinationPolicy>
    <persistenceAdapter>
      <jdbcPersistenceAdapter dataSource="#mysql-ds"/>
    </persistenceAdapter>
    <transportConnectors>
       <transportConnector name="default" uri="tcp://localhost:61616"
discoveryUri="multicast://default"/>
       <transportConnector name="stomp"   uri="stomp://localhost:61613"/>
    </transportConnectors>
    <networkConnectors>
      <!-- by default just auto discover the other brokers -->
      <networkConnector name="default" uri="multicast://default"/>
    </networkConnectors>
  </broker>
  <!--  This xbean configuration file supports all the standard spring xml
configuration options -->
  <!-- MySql DataSource Sample Setup -->
  <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 -->


Pico Florin wrote:
> 
> Hi!
>    Can you send me the exactly code that you  wrote in the  xml-file where
> you set up this funxtionality? Also, I would like to  know if it is
> possible to set up this configuration programatically not  in a
> configuration file.
>    Thanks,
>     Florin
> 
>  		
> ---------------------------------
>  The all-new Yahoo! Mail goes wherever you go - free your email address
> from your Internet provider.
> 

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


Re: Don't need a journal for the BrokerService

Posted by Pico Florin <pi...@yahoo.co.uk>.
Hi!
   Can you send me the exactly code that you  wrote in the  xml-file where you set up this funxtionality? Also, I would like to  know if it is possible to set up this configuration programatically not  in a configuration file.
   Thanks,
    Florin

 		
---------------------------------
 The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider.

Re: Don't need a journal for the BrokerService

Posted by Pico Florin <pi...@yahoo.co.uk>.
Thank you for you 
response!
    I need something like this:
  BrokerService jmsServer = new BrokerService();
   jmsServer.doNotLoadTheMessagesFromJournal(); 
  //or
  jmsServer.ignoreMessagesFromJournal();
  That means when the server will ignore the journal messages for all 
the  clients that will be connected on it. In order to be more clear, I 
will  explain why I need this functionality:
    You have a client that sends a message "Message 1" and the server 
will reply with the "Message 1", and so on.
   Client sends "Message 2" and receives "Message 2" from the server
   Client sends "Message 3" and receives "Message 3" from the server
  Client sends "Message 4" and the client is shut down before to 
receive the message from server.
  When the client is reconnect to the server(that is running therefore  
the setting deleteAllMessagesOnStartup will no work) and sends the  
"Message 1" I want that the server to reply with "Message 1" not with  the 
"Message 4" that is kept in the journal.
   Thanks,
    Florin
  
 		
---------------------------------
 Try the all-new Yahoo! Mail . "The New Version is radically easier to use" – The Wall Street Journal

Re: Don't need a journal for the BrokerService

Posted by James Strachan <ja...@gmail.com>.
On 10/4/06, HU <go...@hotmail.com> wrote:
>
> I did not find any files under the path defined in dataDirectory of
> activemq.xml, so I think the journal file maybe stored on the DB
> table:activemq_msgs, as I found a field is BLOB data of this table. OK, It
> is my misunderstand.

Yes - the journal is a file - its not stored in the database.

> Now, I have started a test without journal setting but the receiving session
> is with transaction.

You've lost me there

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Don't need a journal for the BrokerService

Posted by HU <go...@hotmail.com>.
I did not find any files under the path defined in dataDirectory of
activemq.xml, so I think the journal file maybe stored on the DB
table:activemq_msgs, as I found a field is BLOB data of this table. OK, It
is my misunderstand.

Now, I have started a test without journal setting but the receiving session
is with transaction.



James.Strachan wrote:
> 
> On 10/4/06, HU <go...@hotmail.com> wrote:
>>
>> OK, I did the seting.
>>
>> After I started the broker, it did not recover the journal message from
>> DB.
>> But I found the journal message is still staying in the
>> table:activemq_msgs
>> of Mysql DB Activemq.
> 
> I don't follow what you mean by "the journal message". The journal =
> a number of files we use as a transaction log. If you disable the
> journal, those files are no longer used. The DB is still used to store
> messages.
> 
> If what you want is to completely disable persistence, thats another
> thing - see the bottom of this page...
> http://activemq.org/site/persistence.html
> 
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 

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


Re: Don't need a journal for the BrokerService

Posted by James Strachan <ja...@gmail.com>.
On 10/4/06, HU <go...@hotmail.com> wrote:
>
> OK, I did the seting.
>
> After I started the broker, it did not recover the journal message from DB.
> But I found the journal message is still staying in the table:activemq_msgs
> of Mysql DB Activemq.

I don't follow what you mean by "the journal message". The journal =
a number of files we use as a transaction log. If you disable the
journal, those files are no longer used. The DB is still used to store
messages.

If what you want is to completely disable persistence, thats another
thing - see the bottom of this page...
http://activemq.org/site/persistence.html

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Don't need a journal for the BrokerService

Posted by HU <go...@hotmail.com>.
OK, I did the seting.

After I started the broker, it did not recover the journal message from DB.
But I found the journal message is still staying in the table:activemq_msgs
of Mysql DB Activemq.



James.Strachan wrote:
> 
> On 10/4/06, Pico Florin <pi...@yahoo.co.uk> wrote:
>> Hi!
>>     I would like to ask you if there is any possibilities to set up  the
>> BrokerService in order does not keep a journal of messages? I've 
>> observerd that you could set up the BrokerService to delete all  messages
>> on startup but if the service is starded once on a server how  can I
>> delete them? It should be a way to set up this functionality.
> 
> this page describes how to use pure JDBC without the journal
> http://incubator.apache.org/activemq/persistence.html
> 
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 

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


Re: Don't need a journal for the BrokerService

Posted by James Strachan <ja...@gmail.com>.
On 10/4/06, Pico Florin <pi...@yahoo.co.uk> wrote:
> Hi!
>     I would like to ask you if there is any possibilities to set up  the BrokerService in order does not keep a journal of messages? I've  observerd that you could set up the BrokerService to delete all  messages on startup but if the service is starded once on a server how  can I delete them? It should be a way to set up this functionality.

this page describes how to use pure JDBC without the journal
http://incubator.apache.org/activemq/persistence.html

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Broker used up the memory

Posted by James Strachan <ja...@gmail.com>.
Its also worth saying that the LocalTransactionId objects are pretty
small, so shouldn't be taking up much RAM. Though I guess we should
make it configurable how many little objects to keep around in the
OpenWire cache.

On 10/6/06, Hiram Chirino <hi...@hiramchirino.com> wrote:
> It's normal for open wire to hang on to some cached objects for each
> connection while the connection is still active.  This is part of the value
> caching feature of openwire.  Openwire will hang on to up to 16383 cached
> values per connection.  Perhaps this number is a little high.  We should
> make that a negotiated option in openwire.
>
> On 10/4/06, HU <go...@hotmail.com> wrote:
> >
> >
> >
> > >>Yes - but which object is retaining it?
> >
> > I am not sure but I guess if those objects concern with the holding
> > LocalTransactionId:
> >
> > 1, [47] of org.apache.activemq.command.DataStructure[16383]
> >       marshallCache of org.apache.activemq.openwire.OpenWireFormat[Stack
> > Local]
> > 2, key of java.util.HashMap$Entry
> >        [3940] of java.util.HashMapA$Entry[4097]
> >          table of java.util.HashMap
> >             marshallCacheMap of
> > org.apache.activemq.openwire.OpenWireFormat[Stack Local]
> >
> > Those are copy from yourKit tool:
> >   GC Roots -> Instances of class
> > 'org.apache.activemq.command.LocalTransactionId'
> >
> >
> > --
> > View this message in context:
> > http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6635134
> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> >
> >
>
>
> --
> Regards,
> Hiram
>
> Blog: http://hiramchirino.com
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Broker used up the memory

Posted by Hiram Chirino <hi...@hiramchirino.com>.
Hey Kelly,

I just added a configuration option so that the size of the cache can be
set.  I've also reduced the default cache size to 1024.
http://issues.apache.org/activemq/browse/AMQ-1001 tracked the issue.

Changes are committed to trunk in case you want to test them out.

On 10/6/06, Kelly Campbell <ke...@gmail.com> wrote:
>
> I filed a bug regarding that behaviour a while back. It's 64k for the
> openwire structures even when they're empty. This uses up the available
> heap
> quickly. :-(
>
> On 10/5/06, Hiram Chirino <hi...@hiramchirino.com> wrote:
> >
> > It's normal for open wire to hang on to some cached objects for each
> > connection while the connection is still active.  This is part of the
> > value
> > caching feature of openwire.  Openwire will hang on to up to 16383
> cached
> > values per connection.  Perhaps this number is a little high.  We should
> > make that a negotiated option in openwire.
> >
> > On 10/4/06, HU <go...@hotmail.com> wrote:
> > >
> > >
> > >
> > > >>Yes - but which object is retaining it?
> > >
> > > I am not sure but I guess if those objects concern with the holding
> > > LocalTransactionId:
> > >
> > > 1, [47] of org.apache.activemq.command.DataStructure[16383]
> > >       marshallCache of org.apache.activemq.openwire.OpenWireFormat
> [Stack
> > > Local]
> > > 2, key of java.util.HashMap$Entry
> > >        [3940] of java.util.HashMapA$Entry[4097]
> > >          table of java.util.HashMap
> > >             marshallCacheMap of
> > > org.apache.activemq.openwire.OpenWireFormat[Stack Local]
> > >
> > > Those are copy from yourKit tool:
> > >   GC Roots -> Instances of class
> > > 'org.apache.activemq.command.LocalTransactionId'
> > >
> > >
> > > --
> > > View this message in context:
> > >
> http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6635134
> > > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> > >
> > >
> >
> >
> > --
> > Regards,
> > Hiram
> >
> > Blog: http://hiramchirino.com
> >
> >
>
>


-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Re: Broker used up the memory

Posted by Kelly Campbell <ke...@gmail.com>.
I filed a bug regarding that behaviour a while back. It's 64k for the
openwire structures even when they're empty. This uses up the available heap
quickly. :-(

On 10/5/06, Hiram Chirino <hi...@hiramchirino.com> wrote:
>
> It's normal for open wire to hang on to some cached objects for each
> connection while the connection is still active.  This is part of the
> value
> caching feature of openwire.  Openwire will hang on to up to 16383 cached
> values per connection.  Perhaps this number is a little high.  We should
> make that a negotiated option in openwire.
>
> On 10/4/06, HU <go...@hotmail.com> wrote:
> >
> >
> >
> > >>Yes - but which object is retaining it?
> >
> > I am not sure but I guess if those objects concern with the holding
> > LocalTransactionId:
> >
> > 1, [47] of org.apache.activemq.command.DataStructure[16383]
> >       marshallCache of org.apache.activemq.openwire.OpenWireFormat[Stack
> > Local]
> > 2, key of java.util.HashMap$Entry
> >        [3940] of java.util.HashMapA$Entry[4097]
> >          table of java.util.HashMap
> >             marshallCacheMap of
> > org.apache.activemq.openwire.OpenWireFormat[Stack Local]
> >
> > Those are copy from yourKit tool:
> >   GC Roots -> Instances of class
> > 'org.apache.activemq.command.LocalTransactionId'
> >
> >
> > --
> > View this message in context:
> > http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6635134
> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> >
> >
>
>
> --
> Regards,
> Hiram
>
> Blog: http://hiramchirino.com
>
>

Re: Broker used up the memory

Posted by Hiram Chirino <hi...@hiramchirino.com>.
It's normal for open wire to hang on to some cached objects for each
connection while the connection is still active.  This is part of the value
caching feature of openwire.  Openwire will hang on to up to 16383 cached
values per connection.  Perhaps this number is a little high.  We should
make that a negotiated option in openwire.

On 10/4/06, HU <go...@hotmail.com> wrote:
>
>
>
> >>Yes - but which object is retaining it?
>
> I am not sure but I guess if those objects concern with the holding
> LocalTransactionId:
>
> 1, [47] of org.apache.activemq.command.DataStructure[16383]
>       marshallCache of org.apache.activemq.openwire.OpenWireFormat[Stack
> Local]
> 2, key of java.util.HashMap$Entry
>        [3940] of java.util.HashMapA$Entry[4097]
>          table of java.util.HashMap
>             marshallCacheMap of
> org.apache.activemq.openwire.OpenWireFormat[Stack Local]
>
> Those are copy from yourKit tool:
>   GC Roots -> Instances of class
> 'org.apache.activemq.command.LocalTransactionId'
>
>
> --
> View this message in context:
> http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6635134
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Re: Don't need a journal for the BrokerService

Posted by HU <go...@hotmail.com>.
Yes, I do not need to keep the journals of message at all, if you tell me how
to setup the configure file, I'd like to  ignore the journal.
Now, I am using the activemq.xml(with MySql DB) to run a broker as broker
service.
 

Pico Florin wrote:
> 
> Hi!
>     I would like to ask you if there is any possibilities to set up  the
> BrokerService in order does not keep a journal of messages? I've 
> observerd that you could set up the BrokerService to delete all  messages
> on startup but if the service is starded once on a server how  can I
> delete them? It should be a way to set up this functionality.
>   
>   Thank you,
>     Florin
>    
>   
>   
>  		
> ---------------------------------
>  Inbox full of spam? Get leading spam protection and 1GB storage with All
> New Yahoo! Mail.
> 

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


Don't need a journal for the BrokerService

Posted by Pico Florin <pi...@yahoo.co.uk>.
Hi!
    I would like to ask you if there is any possibilities to set up  the BrokerService in order does not keep a journal of messages? I've  observerd that you could set up the BrokerService to delete all  messages on startup but if the service is starded once on a server how  can I delete them? It should be a way to set up this functionality.
  
  Thank you,
    Florin
   
  
  
 		
---------------------------------
 Inbox full of spam? Get leading spam protection and 1GB storage with All New Yahoo! Mail.

Re: Broker used up the memory

Posted by HU <go...@hotmail.com>.

>>Yes - but which object is retaining it?

I am not sure but I guess if those objects concern with the holding
LocalTransactionId:

1, [47] of org.apache.activemq.command.DataStructure[16383]
      marshallCache of org.apache.activemq.openwire.OpenWireFormat[Stack
Local]
2, key of java.util.HashMap$Entry
       [3940] of java.util.HashMapA$Entry[4097]
         table of java.util.HashMap
            marshallCacheMap of
org.apache.activemq.openwire.OpenWireFormat[Stack Local]

Those are copy from yourKit tool:
  GC Roots -> Instances of class
'org.apache.activemq.command.LocalTransactionId'

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


Re: Broker used up the memory

Posted by James Strachan <ja...@gmail.com>.
On 10/4/06, HU <go...@hotmail.com> wrote:
> >>Do you know which type is keeping hold of the references to the
> >>TransactionID?
>
> I found an "org.apache.activemq.command.LocalTransactionId" was retained
> after received one message used by session with transaction by YourKit
> profile tool.

Yes - but which object is retaining it?

> >> Are you creating 2 sessions for the entire
> >>duration of the program or creating lots of them? Its definitely the
> >>consumer which is running out of RAM right?
>
> Yes, I am just using one session for receiving message and use other one
> session for sending respond, there is no any more sessions else in my test
> codes. The session of receiving is with transaction.
> After I  changed the session to without transaction, the memory
> leak(OutOfMemory error) was disappear on my test.

Great - so its related to transaction handling. Now we just need to
know which object is keeping hold of the transaction Id objects -
after looking through the code I couldn't see a leak if the same
session object is used for many transactions as as soon as a
transaction starts the previous LocalTransactionId is replaced.

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Broker used up the memory

Posted by HU <go...@hotmail.com>.
>>Do you know which type is keeping hold of the references to the
>>TransactionID?

I found an "org.apache.activemq.command.LocalTransactionId" was retained
after received one message used by session with transaction by YourKit
profile tool.

>> Are you creating 2 sessions for the entire
>>duration of the program or creating lots of them? Its definitely the
>>consumer which is running out of RAM right?

Yes, I am just using one session for receiving message and use other one
session for sending respond, there is no any more sessions else in my test
codes. The session of receiving is with transaction.
After I  changed the session to without transaction, the memory
leak(OutOfMemory error) was disappear on my test.



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


Re: Broker used up the memory

Posted by James Strachan <ja...@gmail.com>.
On 10/3/06, HU <go...@hotmail.com> wrote:
>
> Hi, James
>
> The object TransactionID seemed not be released after commit so that the
> heap was used up and the OutOfMemory error occurred again on my test which
> just used a connecion, 2 sessions(one is for receive request message the
> other one is for send  respond message), a producer and a consumer.

Do you know which type is keeping hold of the references to the
TransactionID? Looking at ActiveMQSession, it seems to get rid of any
transactionID references. Are you creating 2 sessions for the entire
duration of the program or creating lots of them? Its definitely the
consumer which is running out of RAM right?
-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Broker used up the memory

Posted by HU <go...@hotmail.com>.
Hi, James

The object TransactionID seemed not be released after commit so that the
heap was used up and the OutOfMemory error occurred again on my test which
just used a connecion, 2 sessions(one is for receive request message the
other one is for send  respond message), a producer and a consumer.
Of course, I put the new ActiveMQObjectMessage.java which updated by Hiroshi
Ayukawa shown as below in my java code.


Hiroshi Ayukawa wrote:
> 
> Hi, all.
> 
> org.apache.activemq.command.ActiveMQObjectMessage#storeContent() is
> supposed to be buggy.
> 
> ObjectOutputStream should be reset as well as other parts of acticemq do.
> ----------------------------------- Line 98--100 should be.. 
> --------------------------------------------------------------
>                 ObjectOutputStream objOut = new
> ObjectOutputStream(dataOut);
>                 objOut.writeObject(object);
> +              objOut.flush();
> +              objOut.reset();
>                 objOut.close();
> --------------------------------------------------------------------------------------------------------------------------------------
> 
> cf.  http://java.sun.com/products/jdk/serialization/faq/#OutOfMemoryError
> 

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


Re: Broker used up the memory

Posted by Hiroshi Ayukawa <ay...@gmail.com>.
Hi, all.

org.apache.activemq.command.ActiveMQObjectMessage#storeContent() is supposed
to be buggy.

ObjectOutputStream should be reset as well as other parts of acticemq do.
----------------------------------- Line 98--100 should be.. 
--------------------------------------------------------------
                ObjectOutputStream objOut = new ObjectOutputStream(dataOut);
                objOut.writeObject(object);
+              objOut.flush();
+              objOut.reset();
                objOut.close();
--------------------------------------------------------------------------------------------------------------------------------------

cf.  http://java.sun.com/products/jdk/serialization/faq/#OutOfMemoryError
-- 
View this message in context: http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6598182
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Broker used up the memory

Posted by HU <go...@hotmail.com>.
Sorry, I typo the object name that is the "org.apache.activemq.command".
I found it in the memory snapshot files of the profile tool Yourkit which I
have put into the
http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6540031
.
The file:
ConsumerController-2006-09-28(5).memory
is a memory snapshot at the begin of the test.

file:
ConsumerController-2006-09-29(246).memory
is a memory snapshot which was gotten at the nearest the memory leak of the
test.

I think it will give you some hints to fix it fast.

Please find the upload file of this message. I reupload it with this
message.
http://www.nabble.com/file/225/SendToJames.zip SendToJames.zip 
-- 
View this message in context: http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6576306
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Broker used up the memory

Posted by James Strachan <ja...@gmail.com>.
On 9/29/06, HU <go...@hotmail.com> wrote:
>
> Hi, James.
>
> I think I found the guy who eat memory.
>
> On the consumer thread side, it creates a session and a producer for
> replying a message once received a message.

So first of all you should not create a session and producer for every
message...

http://incubator.apache.org/activemq/how-do-i-use-jms-efficiently.html

just use a single session & producer for sending all replies.


> Although I explicitly closed the producer and the session after send the
> respond message, the ActiveMQ seems do not clear the producerID and the
> sessionID from the Object "org.apache.command",

There's no such package or class - do you mean
org.apache.activemq.command? If so thats a package, not a class so
doesn't help too much.

>  so that the memory be used
> slow up by those closed SessionIDs and ProducerIDs with other object
> associates them.
>
> Could you tell me how to release the SessionIDs and ProducerIDs.

I'd like to find out where the objects are being kept. AFAIK the main
place they are rept around is the Connection keeps a collection of
Session objects - which when the session is closed it removes. Could
you find out if the connection is keeping the session objects from
being GC'd?

I just added a try/finally to ActiveMQSession.java so that if the
close of the session fails, it wll definitely still get removed from
teh connection. - maybe that fixes your issue?
-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Broker used up the memory

Posted by HU <go...@hotmail.com>.
Hi, James.

I think I found the guy who eat memory.

On the consumer thread side, it creates a session and a producer for
replying a message once received a message.
Although I explicitly closed the producer and the session after send the
respond message, the ActiveMQ seems do not clear the producerID and the
sessionID from the Object "org.apache.command", so that the memory be used
slow up by those closed SessionIDs and ProducerIDs with other object
associates them.

Could you tell me how to release the SessionIDs and ProducerIDs.



HU wrote:
> 
> Hi, I ran the test with youkit profiler and got the memory snapshot files
> about every 3 minutes.
> Please find the upload files.
> 
> 
> James.Strachan wrote:
>> 
>> Is just the consumer running in the JVM and the broker & producer are
>> seperate? If you think you've found some kind of memory leak, please
>> run a profiler to help us figure out whats going on.
>> 
>> On 9/28/06, HU <go...@hotmail.com> 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 <go...@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 <go...@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#a6539530
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
>>>
>> 
>> 
>> -- 
>> 
>> James
>> -------
>> http://radio.weblogs.com/0112098/
>> 
>> 
>  http://www.nabble.com/file/225/SendToJames.zip SendToJames.zip 
> 

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


Re: Broker used up the memory

Posted by HU <go...@hotmail.com>.
Hi, I ran the test with youkit profiler and got the memory snapshot files
about every 3 minutes.
Please find the upload files.


James.Strachan wrote:
> 
> Is just the consumer running in the JVM and the broker & producer are
> seperate? If you think you've found some kind of memory leak, please
> run a profiler to help us figure out whats going on.
> 
> On 9/28/06, HU <go...@hotmail.com> 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 <go...@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 <go...@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#a6539530
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 
http://www.nabble.com/file/225/SendToJames.zip SendToJames.zip 
-- 
View this message in context: http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6559766
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Broker used up the memory

Posted by HU <go...@hotmail.com>.
Yes, the consumer is separated from the broker and the producer.
Now, I installed the YourKit on the consumer PC and run it to try capture
somthing. 
I put follow codes in my source code, then find the used memory was released
in every 10minuts.
...
final Thread thread = new Thread(
  new Runnable(){
    public void run() {
      try {
        final Controller controller = new Controller();
        for (;;) {
          Thread.sleep(10 /* minutes */ * 60 /*seconds in minute*/ * 1000 /*
millis in second */);
          controller.captureMemorySnapshot();
        }
      }
      catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
);
thread.setDaemon(true); // let the application normally terminate
thread.start();
....

 

Is just the consumer running in the JVM and the broker & producer are
seperate? If you think you've found some kind of memory leak, please
run a profiler to help us figure out whats going on.

On 9/28/06, HU <go...@hotmail.com> 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...
>
>
>

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


Re: Broker used up the memory

Posted by Kelly Campbell <ke...@gmail.com>.
I filed a bug in Jira a few days ago with details about the memory
problems I'm seeing, including a heap histogram that shows it's in the
openwire cache. It allocates lots of 64kb arrays.

On 9/28/06, James Strachan <ja...@gmail.com> wrote:
> Is just the consumer running in the JVM and the broker & producer are
> seperate? If you think you've found some kind of memory leak, please
> run a profiler to help us figure out whats going on.
>
> On 9/28/06, HU <go...@hotmail.com> 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 <go...@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 <go...@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#a6539530
> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> >
> >
>
>
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/
>

Re: Broker used up the memory

Posted by James Strachan <ja...@gmail.com>.
Is just the consumer running in the JVM and the broker & producer are
seperate? If you think you've found some kind of memory leak, please
run a profiler to help us figure out whats going on.

On 9/28/06, HU <go...@hotmail.com> 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 <go...@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 <go...@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#a6539530
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Broker used up the memory

Posted by HU <go...@hotmail.com>.
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 <go...@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 <go...@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#a6539530
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Broker used up the memory

Posted by James Strachan <ja...@gmail.com>.
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 <go...@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 <go...@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/

Re: Broker used up the memory

Posted by HU <go...@hotmail.com>.

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 <go...@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.


Re: Broker used up the memory

Posted by James Strachan <ja...@gmail.com>.
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 <go...@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/

Re: Broker used up the memory

Posted by HU <go...@hotmail.com>.
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.


Re: Broker used up the memory

Posted by James Strachan <ja...@gmail.com>.
Move the XML attribute

 xmlns="http://activemq.org/config/1.0"

from the <beans> to the <broker> element

On 9/25/06, HU <go...@hotmail.com> wrote:
>
> I encountered an error like below:
> ERROR: java.lang.RuntimeException: Failed to execute start task. Reason:
> org.springframework.beans.factory.BeanDefinitionStoreException: Error
> registering bean with name '' defined in class path resource [activemq.xml]:
> Bean class [jdbcPersistence] not found; nested exception is
> java.lang.ClassNotFoundException: jdbcPersistence
>
> after i start activemq by changing the config file:activemq.xml:
>
> <!-- START SNIPPET: example -->
> <beans xmlns="http://activemq.org/config/1.0">
>
>   <!-- Allows us to use system properties as variables in this configuration
> file -->
>   <bean
> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
>
>   <broker useJmx="true">
>
>     <!-- In ActiveMQ 4, you can setup destination policies -->
>     <destinationPolicy>
>       <policyMap><policyEntries>
>
>           <policyEntry topic="FOO.>">
>             <dispatchPolicy>
>               <strictOrderDispatchPolicy />
>             </dispatchPolicy>
>             <subscriptionRecoveryPolicy>
>               <lastImageSubscriptionRecoveryPolicy />
>             </subscriptionRecoveryPolicy>
>           </policyEntry>
>
>       </policyEntries></policyMap>
>     </destinationPolicy>
>     <persistenceAdapter>
>         <jdbcPersistence dataSourceRef="mssql-ds"/>
>
>         <!--<journaledJDBC journalLogFiles="5"
> dataDirectory="${activemq.home}/activemq-data"/>-->
>
>       <!-- To use a different datasource, use th following syntax : -->
>       <!--
>       <journaledJDBC journalLogFiles="5" dataDirectory="../activemq-data"
> dataSource="#postgres-ds"/>
>        -->
>     </persistenceAdapter>
>
>     <transportConnectors>
>        <transportConnector name="default" uri="tcp://localhost:61616"
> discoveryUri="multicast://default"/>
>        <transportConnector name="stomp"   uri="stomp://localhost:61613"/>
>     </transportConnectors>
>
>     <networkConnectors>
>       <!-- by default just auto discover the other brokers -->
>       <networkConnector name="default" uri="multicast://default"/>
>       <!--
>       <networkConnector name="host1 and host2"
> uri="static://(tcp://host1:61616,tcp://host2:61616)" failover="true"/>
>       -->
>     </networkConnectors>
>
>   </broker>
>
>   <!--  This xbean configuration file supports all the standard spring xml
> configuration options -->
>
>   <!-- MySql DataSource Sample Setup -->
>   <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 -->
>
> I have placed the MySql jdbc driver in the directory
> "activemq_home/lib/optional".
>
>
> James.Strachan wrote:
> >
> > If you look in activemq.xml you should see an uncommented chunk of XML
> > for configuring the MySQL JDBC details
> >
> > On 9/25/06, HU <go...@hotmail.com> wrote:
> >>
> >> I am a beginner in ActiveMQ. Could you please tell me how to use ActiveMQ
> >> with MySQL DB.
> >>
> >> HU
> >>
> >> James.Strachan wrote:
> >> >
> >> > Try increasing your heap size via java -Xmx=512m or something. If you
> >> > want to reduce your RAM footprint use the <usageManager> element and
> >> > try using a database in another process (MySQL/Postgresql) rather than
> >> > the embedded Derby.
> >> >
> >> >
> >> > On 9/22/06, HU <go...@hotmail.com> wrote:
> >> >>
> >> >> I did a test as below:
> >> >> 1, use below codes to start a broker thread that only create 2 queues:
> >> >>
> >> >> BrokerService broker = new BrokerService();
> >> >> broker.addConnector("tcp://localhost:61616");
> >> >> broker.start();
> >> >> ActiveMQConnectionFactory connectionFactory;
> >> >> connectionFactory = new ActiveMQConnectionFactory(
> >> >> "failover:tcp://localhost:61616");
> >> >>
> >> >> 2, create a sender thread and  a consumer thread which use the 2
> >> queues.
> >> >> 3, Send a mesesage from sender thread through a queue then receive the
> >> >> message on the consumer thread.
> >> >> 4, Send a message from consumer thread through another queue and
> >> recieve
> >> >> the
> >> >> message on the sender thread.
> >> >> 5, repeat 3 and 4.
> >> >>
> >> >> After send about 380 messages from sendder thread, an error occurred
> >> on
> >> >> the
> >> >> broker thread which is:
> >> >> Thread[ActiveMQ Transport server: tcp//XXX:61616]( Interrupting...
> >> >> (Exception OutOfMemoryError)
> >> >>  OpenWireFormat.<int>(int) Line:62
> >> >> ....
> >> >>
> >> >> Could someone tell me please how to resolve the problem.
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6444443
> >> >> 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#a6482630
> >> 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#a6484245
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Broker used up the memory

Posted by HU <go...@hotmail.com>.
I encountered an error like below:
ERROR: java.lang.RuntimeException: Failed to execute start task. Reason:
org.springframework.beans.factory.BeanDefinitionStoreException: Error
registering bean with name '' defined in class path resource [activemq.xml]:
Bean class [jdbcPersistence] not found; nested exception is
java.lang.ClassNotFoundException: jdbcPersistence

after i start activemq by changing the config file:activemq.xml:

<!-- START SNIPPET: example -->
<beans xmlns="http://activemq.org/config/1.0">

  <!-- Allows us to use system properties as variables in this configuration
file -->
  <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>

  <broker useJmx="true">

    <!-- In ActiveMQ 4, you can setup destination policies -->
    <destinationPolicy>
      <policyMap><policyEntries>

          <policyEntry topic="FOO.>">
            <dispatchPolicy>
              <strictOrderDispatchPolicy />
            </dispatchPolicy>
            <subscriptionRecoveryPolicy>
              <lastImageSubscriptionRecoveryPolicy />
            </subscriptionRecoveryPolicy>
          </policyEntry>

      </policyEntries></policyMap>
    </destinationPolicy>
    <persistenceAdapter>
        <jdbcPersistence dataSourceRef="mssql-ds"/>
        
        <!--<journaledJDBC journalLogFiles="5"
dataDirectory="${activemq.home}/activemq-data"/>-->
        
      <!-- To use a different datasource, use th following syntax : -->
      <!--
      <journaledJDBC journalLogFiles="5" dataDirectory="../activemq-data"
dataSource="#postgres-ds"/>
       -->
    </persistenceAdapter>

    <transportConnectors>
       <transportConnector name="default" uri="tcp://localhost:61616"
discoveryUri="multicast://default"/>
       <transportConnector name="stomp"   uri="stomp://localhost:61613"/>
    </transportConnectors>

    <networkConnectors>
      <!-- by default just auto discover the other brokers -->
      <networkConnector name="default" uri="multicast://default"/>
      <!--
      <networkConnector name="host1 and host2"
uri="static://(tcp://host1:61616,tcp://host2:61616)" failover="true"/>
      -->
    </networkConnectors>

  </broker>

  <!--  This xbean configuration file supports all the standard spring xml
configuration options -->

  <!-- MySql DataSource Sample Setup -->
  <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 -->

I have placed the MySql jdbc driver in the directory
"activemq_home/lib/optional".
 

James.Strachan wrote:
> 
> If you look in activemq.xml you should see an uncommented chunk of XML
> for configuring the MySQL JDBC details
> 
> On 9/25/06, HU <go...@hotmail.com> wrote:
>>
>> I am a beginner in ActiveMQ. Could you please tell me how to use ActiveMQ
>> with MySQL DB.
>>
>> HU
>>
>> James.Strachan wrote:
>> >
>> > Try increasing your heap size via java -Xmx=512m or something. If you
>> > want to reduce your RAM footprint use the <usageManager> element and
>> > try using a database in another process (MySQL/Postgresql) rather than
>> > the embedded Derby.
>> >
>> >
>> > On 9/22/06, HU <go...@hotmail.com> wrote:
>> >>
>> >> I did a test as below:
>> >> 1, use below codes to start a broker thread that only create 2 queues:
>> >>
>> >> BrokerService broker = new BrokerService();
>> >> broker.addConnector("tcp://localhost:61616");
>> >> broker.start();
>> >> ActiveMQConnectionFactory connectionFactory;
>> >> connectionFactory = new ActiveMQConnectionFactory(
>> >> "failover:tcp://localhost:61616");
>> >>
>> >> 2, create a sender thread and  a consumer thread which use the 2
>> queues.
>> >> 3, Send a mesesage from sender thread through a queue then receive the
>> >> message on the consumer thread.
>> >> 4, Send a message from consumer thread through another queue and
>> recieve
>> >> the
>> >> message on the sender thread.
>> >> 5, repeat 3 and 4.
>> >>
>> >> After send about 380 messages from sendder thread, an error occurred
>> on
>> >> the
>> >> broker thread which is:
>> >> Thread[ActiveMQ Transport server: tcp//XXX:61616]( Interrupting...
>> >> (Exception OutOfMemoryError)
>> >>  OpenWireFormat.<int>(int) Line:62
>> >> ....
>> >>
>> >> Could someone tell me please how to resolve the problem.
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6444443
>> >> 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#a6482630
>> 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#a6484245
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Broker used up the memory

Posted by James Strachan <ja...@gmail.com>.
If you look in activemq.xml you should see an uncommented chunk of XML
for configuring the MySQL JDBC details

On 9/25/06, HU <go...@hotmail.com> wrote:
>
> I am a beginner in ActiveMQ. Could you please tell me how to use ActiveMQ
> with MySQL DB.
>
> HU
>
> James.Strachan wrote:
> >
> > Try increasing your heap size via java -Xmx=512m or something. If you
> > want to reduce your RAM footprint use the <usageManager> element and
> > try using a database in another process (MySQL/Postgresql) rather than
> > the embedded Derby.
> >
> >
> > On 9/22/06, HU <go...@hotmail.com> wrote:
> >>
> >> I did a test as below:
> >> 1, use below codes to start a broker thread that only create 2 queues:
> >>
> >> BrokerService broker = new BrokerService();
> >> broker.addConnector("tcp://localhost:61616");
> >> broker.start();
> >> ActiveMQConnectionFactory connectionFactory;
> >> connectionFactory = new ActiveMQConnectionFactory(
> >> "failover:tcp://localhost:61616");
> >>
> >> 2, create a sender thread and  a consumer thread which use the 2 queues.
> >> 3, Send a mesesage from sender thread through a queue then receive the
> >> message on the consumer thread.
> >> 4, Send a message from consumer thread through another queue and recieve
> >> the
> >> message on the sender thread.
> >> 5, repeat 3 and 4.
> >>
> >> After send about 380 messages from sendder thread, an error occurred on
> >> the
> >> broker thread which is:
> >> Thread[ActiveMQ Transport server: tcp//XXX:61616]( Interrupting...
> >> (Exception OutOfMemoryError)
> >>  OpenWireFormat.<int>(int) Line:62
> >> ....
> >>
> >> Could someone tell me please how to resolve the problem.
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6444443
> >> 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#a6482630
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Broker used up the memory

Posted by HU <go...@hotmail.com>.
I am a beginner in ActiveMQ. Could you please tell me how to use ActiveMQ
with MySQL DB.

HU

James.Strachan wrote:
> 
> Try increasing your heap size via java -Xmx=512m or something. If you
> want to reduce your RAM footprint use the <usageManager> element and
> try using a database in another process (MySQL/Postgresql) rather than
> the embedded Derby.
> 
> 
> On 9/22/06, HU <go...@hotmail.com> wrote:
>>
>> I did a test as below:
>> 1, use below codes to start a broker thread that only create 2 queues:
>>
>> BrokerService broker = new BrokerService();
>> broker.addConnector("tcp://localhost:61616");
>> broker.start();
>> ActiveMQConnectionFactory connectionFactory;
>> connectionFactory = new ActiveMQConnectionFactory(
>> "failover:tcp://localhost:61616");
>>
>> 2, create a sender thread and  a consumer thread which use the 2 queues.
>> 3, Send a mesesage from sender thread through a queue then receive the
>> message on the consumer thread.
>> 4, Send a message from consumer thread through another queue and recieve
>> the
>> message on the sender thread.
>> 5, repeat 3 and 4.
>>
>> After send about 380 messages from sendder thread, an error occurred on
>> the
>> broker thread which is:
>> Thread[ActiveMQ Transport server: tcp//XXX:61616]( Interrupting...
>> (Exception OutOfMemoryError)
>>  OpenWireFormat.<int>(int) Line:62
>> ....
>>
>> Could someone tell me please how to resolve the problem.
>> --
>> View this message in context:
>> http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6444443
>> 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#a6482630
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Broker used up the memory

Posted by James Strachan <ja...@gmail.com>.
Try increasing your heap size via java -Xmx=512m or something. If you
want to reduce your RAM footprint use the <usageManager> element and
try using a database in another process (MySQL/Postgresql) rather than
the embedded Derby.


On 9/22/06, HU <go...@hotmail.com> wrote:
>
> I did a test as below:
> 1, use below codes to start a broker thread that only create 2 queues:
>
> BrokerService broker = new BrokerService();
> broker.addConnector("tcp://localhost:61616");
> broker.start();
> ActiveMQConnectionFactory connectionFactory;
> connectionFactory = new ActiveMQConnectionFactory(
> "failover:tcp://localhost:61616");
>
> 2, create a sender thread and  a consumer thread which use the 2 queues.
> 3, Send a mesesage from sender thread through a queue then receive the
> message on the consumer thread.
> 4, Send a message from consumer thread through another queue and recieve the
> message on the sender thread.
> 5, repeat 3 and 4.
>
> After send about 380 messages from sendder thread, an error occurred on the
> broker thread which is:
> Thread[ActiveMQ Transport server: tcp//XXX:61616]( Interrupting...
> (Exception OutOfMemoryError)
>  OpenWireFormat.<int>(int) Line:62
> ....
>
> Could someone tell me please how to resolve the problem.
> --
> View this message in context: http://www.nabble.com/Broker-used-up-the-memory-tf2316972.html#a6444443
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/