activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: Performance problem in ActiveMQ4.2-SNAPSHOT
Date Mon, 25 Jun 2007 06:58:44 GMT
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/

Mime
View raw message