IBM Support

IT18725: MQ V8 RESOURCE ADAPTER MEMORY LEAK WHEN USING JMS 2.0 ANONYMOUS MESSAGE PRODUCERS

Subscribe to this APAR

By subscribing, you receive periodic emails alerting you to the status of the APAR, along with a link to the fix after it becomes available. You can track this item individually or track all items by product.

Notify me when this APAR changes.

Notify me when an APAR for this component changes.

 

APAR status

  • Closed as program error.

Error description

  • The IBM MQ V8.0.0.5 resource adapter has been deployed into
    WildFly V10. An enterprise application has also been deployed
    into the same application server. The enterprise application
    contains a servlet that implements the following code
    
    @Inject
    @JMSConnectionFactory("java:jboss/MyConnectionFactory")
    private JMSContext context;
    
    @Resource(lookup = "java:jboss/MyQueue")
    private Queue queue;
    
    protected void doGet(HttpServletRequest req, HttpServletResponse
    resp) throws ServletException, IOException {
      resp.setContentType("text/html");
       try (PrintWriter out = resp.getWriter()){
         out.write("<p>Sending 5 messages to the queue " + queue +
    "</p>");
         for (int i = 0; i < 5; i++) {
           String text = "Message number " + (i + 1);
           context.createProducer().send(queue, text);
           out.write("Message (" + i + "): " + text + "sent
    successfully</br>");
         }
         out.write("<p>All messages sent</p>");
      }
    }
    
    After the application server has been running for a while, it
    reports a java.lang.OutOfMemoryError. A Java heapdump taken when
    the java.lang.OutOfMemoryError occurs shows that there are a
    large number of the following objects on the Java heap:
    
    - com.ibm.mq.connector.outbound.JMSProducerWrapper
    - com.ibm.msg.client.jms.internal.JmsProducerImpl
    
    which are accounting for most of the memory usage.
    

Local fix

Problem summary

  • ****************************************************************
    USERS AFFECTED:
    This issue affects users of:
    
    - The MQ V8.0 resource adapter.
    - The MQ V9.0 resource adapter.
    - The WebSphere Application Server V9.x MQ messaging provider.
    
    who have web-based enterprise applications that:
    
    - Inject a JMSContext object.
    - And create anonymous message producers by calling the JMS 2.0
    Simplified API method Context.createProducer().
    
    
    Platforms affected:
    MultiPlatform
    
    ****************************************************************
    PROBLEM DESCRIPTION:
    The IBM MQ resource adapter maintains an internal list of
    JMSProducer objects that have been created from a JMSContext.
    JMSProducers are added to the list when the JMS 2.0 Simplified
    API method:
    
      Context.createProducer().
    
    is called, and are removed from the list as part of the
    processing within the method:
    
      Context.close()
    
    When a JMSContext was injected into a web-based application such
    as a servlet, then it was created when the servlet was
    initialized and only closed off when the enterprise application
    was either stopped or undeployed. If the servlet created any
    JMSProducer objects, then those objects would be added to the
    internal list maintained by the JMSContext and would remain in
    the list until the JMSContext was closed, even though the
    JMSProducers were no longer in scope.
    
    For example, suppose a servlet contained the following code:
    
    ****************************************************************
    *******
      @Inject
      @JMSConnectionFactory("java:jms/MyConnectionFactory")
      private JMSContext context;
    
      @Resource(lookup = "java:jms/MyQueue")
      private Queue queue;
    
      protected void doGet(HttpServletRequest req,
    HttpServletResponse resp) throws ServletException, IOException {
          resp.setContentType("text/html");
          try (PrintWriter out = resp.getWriter()){
              out.write("Sending 5 messages to the queue " + queue +
    "</p>");
              for (int i = 0; i < 5; i++) {
                  String text = "Message " + (i + 1);
                  context.createProducer().send(queue, text);
                  out.write("Message (" + i + ") sent
    successfully</br>");
              }
              out.write("<p>All messages sent</p>");
          }
      }
    ****************************************************************
    *******
    
    When the servlet was initialized, a JMSContext object was
    created. Every time the servlet's doGet() method was invoked, it
    would create 5 JMSProducer objects, and use those objects to
    send messages. These 5 JMSProducer objects would be added to the
    list of JMSProducers maintained by the JMSContext. When the
    method exited, the JMSProducer objects would go out of scope.
    However, they would remain in the JMSContext's list of
    JMSProducers.
    
    This meant that the list containing the JMSProducers associated
    with the JMSContext would grow every time the doGet() method was
    called.
    

Problem conclusion

  • The MQ resource adapter has been modified so that the JMSContext
    now maintains a list of weak references to the JMSProducers that
    have been created from it. This ensures that the JMSProducer
    objects are cleaned up by the Java Runtime Environment garbage
    collector once they drop out of scope.
    
    ---------------------------------------------------------------
    The fix is targeted for delivery in the following PTFs:
    
    Version    Maintenance Level
    v8.0       8.0.0.7
    v9.0 CD    9.0.4
    v9.0 LTS   9.0.0.2
    
    The latest available maintenance can be obtained from
    'WebSphere MQ Recommended Fixes'
    http://www-1.ibm.com/support/docview.wss?rs=171&uid=swg27006037
    
    If the maintenance level is not yet available information on
    its planned availability can be found in 'WebSphere MQ
    Planned Maintenance Release Dates'
    http://www-1.ibm.com/support/docview.wss?rs=171&uid=swg27006309
    ---------------------------------------------------------------
    

Temporary fix

Comments

APAR Information

  • APAR number

    IT18725

  • Reported component name

    WMQ BASE MULTIP

  • Reported component ID

    5724H7251

  • Reported release

    800

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2017-01-12

  • Closed date

    2017-02-13

  • Last modified date

    2017-07-13

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    WMQ BASE MULTIP

  • Fixed component ID

    5724H7251

Applicable component levels

  • R800 PSY

       UP

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSYHRD","label":"IBM MQ"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"8.0.0.0","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
13 July 2017