Possibly Memory leak in PyMongo 4.3.3?

Hi, I am using Apache2 + Flask + PyMongo (4.3.3), there are memory leak observed. I tried Tracemalloc for memory usage snapshot and found top 2 memory consumer here which keep increasing:

lib/python3.10/site-packages/pymongo/message.py:692: size=67.9 KiB (+67.9 KiB), count=1130 (+1130), average=62 B

lib/python3.10/site-packages/bson/init .py:1122: size=42.6 KiB (+42.6 KiB), count=734 (+734), average=59 B

Is it a known issue? Or possibly fixed in 4.5.0?

Thank you very much!

Thanks for the report @Mary_Zhang1! I opened https://jira.mongodb.org/browse/PYTHON-3982 to investigate.

Hi Steve, Thank you very much for help.

@Mary_Zhang1 could you try upgrading to the latest pymongo version (currently 4.8.0) and report back if that resolves this issue?

Hi Shane, thanks for the update. So 4.8.0 release should have the fix? We use AWS DocDB, not sure any compatibility issue? Or which version with the fix we can try? Thank you!

There were many improvements to the C extensions fixed between 4.3.3 to 4.8.0. We’re not sure if any will fix your issue specifically but it would be great to start testing the latest version.

Hi Shane, What about compatibility of PyMongo 4.8 vs AWS DocumentDB 4.0 which supports MongoDB 4.0? Thank you.

We don’t offer technical support for DocumentDB. If you can reproduce the issue with MongoDB then please file an issue with us, otherwise you’ll need to go to DocumentDB.

2 Likes