Hi,
While using the python library `pymqi` we discovered that there is possibly a memory leak with `MQCONNX` when `cd.SSLCipherSpec` is specified and the connection fails.
I used `@profile` from [memory-profiler](https://pypi.org/project/memory-profiler/) for the profiling.
As you can see in the profiling results, the memory increases with each call to `QueueManager .connect_with_options` with then call `MQCONNX`.
You can reproduce by running the `
con_leak.py` (attached) script using `python -m memory_profiler
con_leak.py`.
Line # Mem usage Increment Line Contents
================================================
5 38.3828 MiB 38.3828 MiB @profile(precision=4)
6 def profiled_connect():
7 38.3828 MiB 0.0000 MiB cd = pymqi.CD()
8 38.3828 MiB 0.0000 MiB cd.ChannelName = b'abc'
9 38.3828 MiB 0.0000 MiB cd.ConnectionName = b'abc'
10 38.3828 MiB 0.0000 MiB cd.ChannelType = pymqi.CMQC.MQCHT_CLNTCONN
11 38.3828 MiB 0.0000 MiB cd.TransportType = pymqi.CMQC.MQXPT_TCP
12 38.3828 MiB 0.0000 MiB cd.Version = 6
13 38.3828 MiB 0.0000 MiB cd.SSLCipherSpec = b'mycypher'
14
15 38.3828 MiB 0.0000 MiB sco = pymqi.SCO()
16 38.3828 MiB 0.0000 MiB sco.KeyRepository = b'my_location'
17
18 38.3828 MiB 0.0000 MiB queue_manager = pymqi.QueueManager(None)
19
20 42.5273 MiB 4.1445 MiB connect_with_options(cd, queue_manager, sco)
21 42.6328 MiB 0.1055 MiB connect_with_options(cd, queue_manager, sco)
22 42.6562 MiB 0.0234 MiB connect_with_options(cd, queue_manager, sco)
23 42.6797 MiB 0.0234 MiB connect_with_options(cd, queue_manager, sco)
24 42.7344 MiB 0.0547 MiB connect_with_options(cd, queue_manager, sco)
25 42.7969 MiB 0.0625 MiB connect_with_options(cd, queue_manager, sco)
26 42.8281 MiB 0.0312 MiB connect_with_options(cd, queue_manager, sco)
27 42.8555 MiB 0.0273 MiB connect_with_options(cd, queue_manager, sco)
28 42.8789 MiB 0.0234 MiB connect_with_options(cd, queue_manager, sco)
29 42.9023 MiB 0.0234 MiB connect_with_options(cd, queue_manager, sco)
30 45.6328 MiB 0.0000 MiB for i in range(100):
31 45.6328 MiB 0.0547 MiB connect_with_options(cd, queue_manager, sco)
32 72.3320 MiB 0.0000 MiB for i in range(1000):
33 72.3320 MiB 0.0781 MiB connect_with_options(cd, queue_manager, sco)
As you can see, each call to `connect_with_options` will increment the total memory used.
Test environment info:
Using the same script shared above. The mem leak happen on:
- OSX with IBM MQ Client 9.1.3.0
- REHL 7.8 with IBM MQ Client 9.1.3.0
It does NOT happen on:
- Ubuntu 16.04 with IBM MQ Client 9.1.3.0
More details and discussion can be found on this GitHub issue:
https://github.com/dsuch/pymqi/issues/208 ------------------------------
Alexandre YANG
------------------------------