Sun Java System Message Queue 4.3 Developer's Guide for C Clients

Memory Management

Table 2–14 lists the functions you use to free or deallocate memory allocated by the Message Queue-C client library on behalf of the user. Such deallocation is part of normal memory management and will prevent memory leaks.

The functions MQCloseConnection, MQCloseSession , MQCloseMessageProducer, and MQCloseMessageConsumer are used to free resources associated with connections, sessions, producers, and consumers.

Table 2–14 Functions Used to Free Memory




Frees memory allocated to the specified connection. 


Frees memory allocated to the specified destination. 


Frees memory allocated to the specified message. 


Frees memory allocated to the specified properties handle. 


Frees memory allocated to the specified MQString.

You should free a connection only after you have closed the connection with the MQCloseConnection() function and after all of the application threads associated with this connection and its dependent sessions, producers, and consumers have returned.

You should not free a connection while an application thread is active in a library function associated with this connection or one of its dependent sessions, producers, consumers, and destinations.

Freeing a connection does not release resources held by a message associated with this connection. You must free memory allocated for this message by explicitly calling the MQFreeMessage function.

You should not free a properties handle if the properties handle passed to a function becomes invalid on its return. If you do, you will get an error.