Condividi tramite


The Pool is Full

What does the trace message "The pool of the native MSMQ messages is full. This may affect performance." mean? Is this a problem?

I've seen some people on the WCF forums ask if this message is related to their MSMQ problems. It almost certainly is something that you can ignore. Let me explain what is happening here.

MSMQ messages are heavyweight objects compared to normal XML messages. The MSMQ transports maintain pools of these native MSMQ messages as an optimization. There are separate pools for input and output messages and one pool per sender or receiver. Each pool has a maximum size to control the amount of memory used for pooling messages. There is no functional problem when the pool is either empty or full. The message pools are just a cache. When you try to get a message from an empty pool, a new message is allocated on the spot. When you try to return a message to a full pool, the message is disposed rather than being put into the cache.

You should be able to tell what the trace message means now based on this description. However, there are some problems.

Pooling looks like it will work fine when receiving on a NetMsmq channel. Pooling also looks like it will work fine when receiving on an MsmqIntegration channel. There's no setting for the pool size on an MsmqIntegrationBindingElement, but there is a hard-coded value of 8 in the code. This is the same as the default size for the NetMsmq message pools. When sending on a NetMsmq channel, the pool full message is actually traced when the pool is empty rather than when the pool is full. As far as I can tell, sending on an MsmqIntegration channel doesn't bother with pooling at all and simply creates a message every time through.

Next time: Message Flow Interception Points