Topic
  • 2 replies
  • Latest Post - ‏2013-10-17T08:44:05Z by W5A0_Jonathan_Henson
W5A0_Jonathan_Henson
2 Posts

Pinned topic Purify with WebSphere MQ

‏2013-10-15T14:02:29Z |

Purify with a program linked with mqm.dll

I've been trying to use Purify to diagnose a potential memory leak in an MQ API exit, but even a leak deliberately added to the exit code was not detected.

Leaving behind the API exit, I've been experimenting with a small test program and have observed a difference in behaviour if calls are made to the MQ API.  If the following code is compiled with the MQCONN and MQDISC calls commented out, Purify reports the memory allocated at the first line of main() as a potential leak; with the calls left in place no leak is reported.

#include <stdlib.h>
#include <stdio.h>

#include <cmqc.h>

void main( int argc, char** argv ) {
    void *ptr = malloc( 777000 );
    MQHCONN conn;
    MQLONG compCode, reason;    

    ptr = NULL;
        
    MQCONN( "venus.queue.manager", &conn, &compCode, &reason);
    printf( "MQCONN: compCode: %d, reason: %d\n", compCode, reason );
    
    MQDISC( &conn, &compCode, &reason);
    printf( "MQDISC: compCode: %d, reason: %d\n", compCode, reason );
}


Does anyone have any experience using Purify in conjunction with MQ?

I'm using:

Windows 7
PurifyPlus 7.0.1.0-003 64-bit Build: 20120410.1500
WebSphere MQ 7.0.1.0

Thanks,
Jon

  • AddisonLu
    AddisonLu
    4 Posts

    Re: Purify with WebSphere MQ

    ‏2013-10-17T03:33:00Z  

    Hi Jon,

    You allocated big memory, I wonder if there is enough heap memory available on your machine.

    Try allocating smaller size?

    Regards,

    Addison Lu

  • W5A0_Jonathan_Henson
    2 Posts

    Re: Purify with WebSphere MQ

    ‏2013-10-17T08:44:05Z  
    • AddisonLu
    • ‏2013-10-17T03:33:00Z

    Hi Jon,

    You allocated big memory, I wonder if there is enough heap memory available on your machine.

    Try allocating smaller size?

    Regards,

    Addison Lu

    Hi Addison,

    Thanks for your reply.  My machine has enough memory; the allocation doesn't fail.  I actually started out with a smaller value and just started adding zeros to see if that would make Purify take notice. ;)

    I've started trying to track down the memory leak by simulating the API calls.  Obviously this isn't ideal, but at least Purify reports leaks if I omit the call to Teminate() in my test code (Terminate is the last method called by MQ in order to allow the exit to clear up after itself).

    Clearly it would be preferable to use Purify on the exit code as it would normally be executed in order to determine whether there's an issue with the way in which it is using the MQ API, so any suggestions as to how I could do this would be greatly appreciated.

    Regards,

    Jon