-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dict memory leak in Python 3.12.x / msgpack 1.0.x #612
Comments
The memory leak occurs with both the C version and the fallback version (using Python 3.12). In the fallback module, if you remove the call to
I wonder if Python 3.12 has a regression with the table of interned strings. |
Sounds related: python/cpython#113993 |
I also have seen the memory usage going upwards with just the psutil code in the loop. I didn't compare the magnitude of that with and without the msgpack call though. |
In Python 3.12, it sounds like all intern'd strings are immortal now. The documentation for This ticket explains why msgpack uses intern: #372 Maybe an optional flag could be added to the unpacker, so that applications with many unique keys can opt-out of interning. |
"Many json decoders exploit this and memoize/intern strings, to reduce the memory use of the resulting message" The irony! Optional flag sounds like a nice addition; presumably CPython will fix this particular issue at some point but some other case(s) could exist in the future where interning is not appropriate. |
waiting python/cpython#123065 |
It is fixed in 3.12.7. |
Hello,
I think I've found a second Python 3.12 memory leak (having read the issue for the other one, and tried upgrading to msgpack 1.0.8 to fix).
This issue occurs with dicts, and key uniqueness seems to be a major consideration. (A bunch of dicts with the exact same keys don't cause the problem -- some kind of key caching issue maybe?)
Here's a repro:
Output, msgpack 1.0.8 on Python 3.12.3:
Output, msgpack 0.6.2 on Python 3.12.3 or msgpack 1.0.8 on Python 3.11.9 (slightly different numbers but same effect):
p.s. apologies for using
psutil
in the script, I didn't remember until later that it isn't a Python built-in.The text was updated successfully, but these errors were encountered: