Title: Dict memory leak in Python 3.12.x / msgpack 1.0.x · Issue #612 · msgpack/msgpack-python · GitHub
Open Graph Title: Dict memory leak in Python 3.12.x / msgpack 1.0.x · Issue #612 · msgpack/msgpack-python
X Title: Dict memory leak in Python 3.12.x / msgpack 1.0.x · Issue #612 · msgpack/msgpack-python
Description: 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 bun...
Open Graph Description: 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 s...
X Description: 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 uniquene...
Opengraph URL: https://github.com/msgpack/msgpack-python/issues/612
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Dict memory leak in Python 3.12.x / msgpack 1.0.x","articleBody":"Hello,\r\n\r\nI 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).\r\n\r\nThis 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?)\r\n\r\nHere's a repro:\r\n\r\n```\r\nimport psutil\r\nimport msgpack\r\n\r\n# Set up a list of packed dicts\r\np = [\r\n msgpack.packb(\r\n {f'{p}.{r}': True for r in range(1000)}\r\n )\r\n for p in range(1000)\r\n]\r\n\r\n# Check initial state\r\nprint(f'initial mem: {psutil.Process().memory_info().rss}')\r\n\r\n# Loop and unpack\r\ni = 0\r\nfor x in p:\r\n y = msgpack.unpackb(x)\r\n i += 1\r\n if i % 100 == 0:\r\n print(f'subsequent mem: {psutil.Process().memory_info().rss}')\r\n```\r\n\r\nOutput, msgpack 1.0.8 on Python 3.12.3:\r\n```\r\ninitial mem: 24571904\r\nsubsequent mem: 34029568\r\nsubsequent mem: 42627072\r\nsubsequent mem: 47493120\r\nsubsequent mem: 60088320\r\nsubsequent mem: 64684032\r\nsubsequent mem: 69550080\r\nsubsequent mem: 89878528\r\nsubsequent mem: 94744576\r\nsubsequent mem: 99340288\r\nsubsequent mem: 104206336\r\n```\r\n\r\nOutput, 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):\r\n```\r\ninitial mem: 22761472\r\nsubsequent mem: 23089152\r\nsubsequent mem: 23089152\r\nsubsequent mem: 23089152\r\nsubsequent mem: 23089152\r\nsubsequent mem: 23089152\r\nsubsequent mem: 23089152\r\nsubsequent mem: 23089152\r\nsubsequent mem: 23089152\r\nsubsequent mem: 23089152\r\nsubsequent mem: 23089152\r\n```\r\n\r\np.s. apologies for using `psutil` in the script, I didn't remember until later that it isn't a Python built-in.\r\n","author":{"url":"https://github.com/amachanic","@type":"Person","name":"amachanic"},"datePublished":"2024-05-24T20:15:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/612/msgpack-python/issues/612"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:436f44e3-6359-4dbd-0868-87d78ee7688f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E310:297F82:19DA11B:2394F0F:696AB34C |
| html-safe-nonce | 41d21e71d03d92ca123a507a7c59ed195a9deccf7096556a178c2179d0dd6132 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzEwOjI5N0Y4MjoxOURBMTFCOjIzOTRGMEY6Njk2QUIzNEMiLCJ2aXNpdG9yX2lkIjoiNjAxNDM2OTg2NzQ1NDEzMzA2OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 86da1139db32ad51097d56ba7fcfef995aaa5a66926f39ff99b5415a7dce6371 |
| hovercard-subject-tag | issue:2316191603 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/msgpack/msgpack-python/612/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4fbfa1ae5b94dfb366fa88014901c6e9f1387b00e7cff9f6ff127421e5350093/msgpack/msgpack-python/issues/612 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4fbfa1ae5b94dfb366fa88014901c6e9f1387b00e7cff9f6ff127421e5350093/msgpack/msgpack-python/issues/612 |
| og:image:alt | 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 s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | amachanic |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4fa1799b6a53c2d30c950d74230781bef9e7f61138c72c7727e4b83f0743752b |
| turbo-cache-control | no-preview |
| go-import | github.com/msgpack/msgpack-python git https://github.com/msgpack/msgpack-python.git |
| octolytics-dimension-user_id | 198264 |
| octolytics-dimension-user_login | msgpack |
| octolytics-dimension-repository_id | 2242705 |
| octolytics-dimension-repository_nwo | msgpack/msgpack-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 2242705 |
| octolytics-dimension-repository_network_root_nwo | msgpack/msgpack-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 41f276818bd204c4a30a0281fb3c576298d9474c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width