ibm-messaging / mq-golang

Calling IBM MQ from Go applications
Apache License 2.0
168 stars 60 forks source link

Seems to leak memory in get #99

Closed wcn00 closed 5 years ago

wcn00 commented 5 years ago

Using: -ubuntu 18 linux -mq 9.1.0.1 -current pull from github of mq-golong I'm writing a microservice for sending and getting MQ messages. It supports basic message properties. The put side of the service runs forever in the same memory footprint, but the get side leaks memory. I suspect that the leak is in the C side of the enclave (if thats the right word). go pprof shows nothing unusual. I've rewritten the amqprop sample to get my messages (attached) and when I run it it leaks.
Any ideas? amqsprop.zip

If you need me to make the other side in a sample I can. wcn

wcn00 commented 5 years ago

Adding valgrind report. Seems to indicate that there are cgo allocations not freed. valgrind.zip

ibmmqmet commented 5 years ago

Looks like a buffer in InqMP is being allocated on each iteration and not freed or reused. I'm not in a good environment to fully test a fix right now so might be a few days before I can do anything about it, or to check that really is the issue.

wcn00 commented 5 years ago

I'm in a good spot for that.  I'll test the idea, by allocating the properties header, and then not using it before freeing it. If you're idea pans out I'll test a fix.

wcn

p.s.  Thanks for responding

On 2019-04-16 11:03 a.m., ibmmqmet wrote:

Looks like a buffer in InqMP is being allocated on each iteration and not freed or reused. I'm not in a good environment to fully test a fix right now so might be a few days before I can do anything about it, or to check that really is the issue.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ibm-messaging/mq-golang/issues/99#issuecomment-483760324, or mute the thread https://github.com/notifications/unsubscribe-auth/ADpCDGroxjPPSTZulwsufu2e71Ys9ViCks5vhgJygaJpZM4cw6qo.

wcn00 commented 5 years ago

This diff seems to resolve the issue. Thanks again for the pointer.

`diff --git a/ibmmq/mqi.go b/ibmmq/mqi.go index ba3f54f..f90cc67 100644 --- a/ibmmq/mqi.go +++ b/ibmmq/mqi.go @@ -1198,12 +1198,14 @@ func (handle MQMessageHandle) InqMP(goimpo MQIMPO, gopd *MQPD, name string) (s mqName.VSPtr = (C.MQPTR)(C.malloc(namebufsize)) mqName.VSBufSize = namebufsize }

`

ibmmqmet commented 5 years ago

V4.0.5 includes a fix for this

ibmmqmet commented 5 years ago

closing as delivered