activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From comchyi <comchy...@163.com>
Subject Re: Performance problem in ActiveMQ4.2-SNAPSHOT
Date Tue, 26 Jun 2007 09:00:34 GMT



James.Strachan wrote:
> 
> On 6/25/07, comchyi <comchyi00@163.com> wrote:
>>
>> I find an performance problem in ActiveMQ4.2-SNAPSHOT when
>> i subscribe an topic and consume 500000 messages,the problem
>> is that the memory of CPU is  consumed increasely all long until
>> the  free heap of JVM's memory  is  zone. The client code like this:
>>                          if (message instanceof TextMessage) {
>>                                 txtMsg = (TextMessage) message;
>>                                 String msg = txtMsg.getText();
>>                                 .....
>>                         }
>> I test this code by  JProfiler which is a tool of testing performance
>> ,and
>> find the cause is the method of txtMsg.getText() ,its implement method is
>> the org.apache.activemq.command.ActiveMQTextMessage.getText(),the code of
>> this method is :
>> package org.apache.activemq.command;
>> public class ActiveMQTextMessage extends ActiveMQMessage implements
>> TextMessage {
>> .......
>>  public String getText() throws JMSException {
>>         if (text == null && getContent() != null) {
>>             try {
>>                 ByteSequence bodyAsBytes = getContent();
>>                 if (bodyAsBytes != null) {
>>                     InputStream is = new
>> ByteArrayInputStream(bodyAsBytes);
>>                     if( isCompressed() ) {
>>                         is = new InflaterInputStream(is);
>>                     }
>>                     DataInputStream dataIn = new DataInputStream(is);
>>                     text = MarshallingSupport.readUTF8(dataIn);
>>                     dataIn.close();
>>                     setContent(null);
>>                 }
>>             } catch (IOException ioe) {
>>                 throw JMSExceptionSupport.create(ioe);
>>             }
>>         }
>>         return text;
>>     }
>> ......
>> }
>> In this code ,the instance  " is " is not closed ,i think must invoke
>> the method   in.close() to release the memory of JVM.I  suggest
>> modify the method  ActiveMQTextMessage.getText().
> 
> I don't really see how ByteArrayInputStream or InflaterInputStream are
> memory leaks as they are constructed in each method and take a byte
> sequence, but I've applied a patch to always close it anyway
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 
hi,james.
i see the change  of method  ActiveMQTextMessage.getText(). that you do,but
i find another problem that the memory leak still exits .i find if the new
problem is the method
org.apache.activemq.command.Message.beforeMarshall((WireFormat wireFormat)
).if i add a code in this method ,i find the used heap size of JVM's memory 
descends quickly.the code that i added likes this:
 baos.close();  at the end of method's body.i suggest to chang
org.apache.activemq.command.Message.beforeMarshall((WireFormat wireFormat) )
like this:
 public void beforeMarshall(WireFormat wireFormat) throws IOException {
        // Need to marshal the properties.
        if( marshalledProperties==null && properties!=null ) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            DataOutputStream os = new DataOutputStream(baos);
            MarshallingSupport.marshalPrimitiveMap(properties, os);
            os.close();
            marshalledProperties = baos.toByteSequence();
            baos.close();
        }
    }
-- 
View this message in context: http://www.nabble.com/Performance-problem-in-ActiveMQ4.2-SNAPSHOT-tf3973867s2354.html#a11302156
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message