You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Hiroshi Ayukawa <ay...@gmail.com> on 2006/10/02 11:18:54 UTC

Re: Broker used up the memory

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