ActiveMQ
  1. ActiveMQ
  2. AMQ-4182

Memory Leak for ActiveMQBytesMessage with Compression as true

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 5.5.1
    • Fix Version/s: 5.10.0
    • Component/s: JMS client
    • Labels:
      None
    • Environment:

      Linux(Redhat 5.5), Windows 7

      Description

      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);
      }
      }

      }

        Activity

          People

          • Assignee:
            Dejan Bosanac
            Reporter:
            Jeff Huang
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development