activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Huang (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AMQ-4182) Memory Leak for ActiveMQBytesMessage with Compression as true
Date Thu, 29 Nov 2012 03:58:58 GMT

    [ https://issues.apache.org/jira/browse/AMQ-4182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13506194#comment-13506194
] 

Jeff Huang commented on AMQ-4182:
---------------------------------

Please try to run the test program with -Xmx10M, -X128M, and -X2G, and monitor the JVM memory
usage. Here are the results in my own test system with 8G memory when it was stable:

-Xmx10M
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
15070 root      17   0  429m 123m 9856 S 80.2  1.5   0:48.49 java   

-Xmx128M
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
15115 root      17   0 2808m 2.0g 9856 S 78.6 26.0   0:22.70 java

-X2G
Never stable and the whole system just ran out of memory.

That means when -Xmx is big enough for holding NORMAL objects the GC just won't see the memory
problem at all, which results in the finalize() method won't be executed ever.

                
> Memory Leak for ActiveMQBytesMessage with Compression as true
> -------------------------------------------------------------
>
>                 Key: AMQ-4182
>                 URL: https://issues.apache.org/jira/browse/AMQ-4182
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: JMS client
>    Affects Versions: 5.5.1
>         Environment: Linux(Redhat 5.5), Windows 7
>            Reporter: Jeff Huang
>
> InflaterInputStream is supposed to close explicitly to release resource allocated by
its JNI methods. In ActiveMQBytesMessage, dataIn property is disposed simply without closing
it, which results in some weird memory leak that can't be detected from heap size. It can't
be controlled by -Xmx or -XX:MaxDirectMemorySize.
> Please run the following test program to verify the issue:
> import java.util.concurrent.TimeUnit;
> import javax.jms.BytesMessage;
> import javax.jms.Connection;
> import javax.jms.Session;
> import org.apache.activemq.ActiveMQConnectionFactory;
> import org.apache.activemq.command.ActiveMQBytesMessage;
> /**
>  * A simple test to verify memory leak in ActiveMQBytesMessage.
>  */
> public class Main
> {
>     public static void main(String[] args) throws Exception 
>     {
>         ActiveMQConnectionFactory connFactory = new ActiveMQConnectionFactory("vm://localhost");
>         connFactory.setUseCompression(true);
>         Connection conn = connFactory.createConnection();
>         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
>         BytesMessage message = session.createBytesMessage();
>         
>         message.writeBytes(new byte[1024]);
>         ActiveMQBytesMessage m = (ActiveMQBytesMessage)message;
>         if(!m.isCompressed())
>         {
>             throw new RuntimeException();
>         }
>         
>         
>         while (true)
>         {
>             for (int k = 0; k < 1024; ++k)
>             {
>                 message.reset();
>                 byte[] data = new byte[1024];
>                 message.readBytes(data);
>             }
>             TimeUnit.MILLISECONDS.sleep(10);
>         }
>     }
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message