Title: Memory leak when using docx.Document to parse large word file · Issue #1428 · python-openxml/python-docx · GitHub
Open Graph Title: Memory leak when using docx.Document to parse large word file · Issue #1428 · python-openxml/python-docx
X Title: Memory leak when using docx.Document to parse large word file · Issue #1428 · python-openxml/python-docx
Description: similar issue: #1364 reproduce code: import gc import os import psutil from docx import Document from memory_profiler import profile @profile def main(): file = "test.docx" document = Document(file) del document gc.collect() print( "curr...
Open Graph Description: similar issue: #1364 reproduce code: import gc import os import psutil from docx import Document from memory_profiler import profile @profile def main(): file = "test.docx" document = Document(file...
X Description: similar issue: #1364 reproduce code: import gc import os import psutil from docx import Document from memory_profiler import profile @profile def main(): file = "test.docx" document = Doc...
Opengraph URL: https://github.com/python-openxml/python-docx/issues/1428
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Memory leak when using docx.Document to parse large word file","articleBody":"> similar issue: https://github.com/python-openxml/python-docx/issues/1364\r\n\r\nreproduce code:\r\n\r\n```python\r\nimport gc\r\nimport os\r\n\r\nimport psutil\r\nfrom docx import Document\r\nfrom memory_profiler import profile\r\n\r\n\r\n@profile\r\ndef main():\r\n file = \"test.docx\"\r\n document = Document(file)\r\n\r\n del document\r\n gc.collect()\r\n\r\n print(\r\n \"current process memory: %.4f GB\"\r\n % (psutil.Process(os.getpid()).memory_info().rss / 1024 / 1024 / 1024),\r\n )\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n```\r\n\r\nreproduce file: \r\n[新建 DOCX 文档.docx](https://github.com/user-attachments/files/16927859/DOCX.docx)\r\n\r\noutput:\r\n\r\n```\r\n❯ python test.py\r\ncurrent process memory: 2.6228 GB\r\nFilename: test.py\r\n\r\nLine # Mem usage Increment Occurrences Line Contents\r\n=============================================================\r\n 9 28.3 MiB 28.3 MiB 1 @profile\r\n 10 def main():\r\n 11 28.3 MiB 0.0 MiB 1 file = \"test.docx\"\r\n 12 2685.7 MiB 2657.4 MiB 1 document = Document(file)\r\n 13\r\n 14 2685.7 MiB 0.0 MiB 1 del document\r\n 15 2685.7 MiB 0.0 MiB 1 gc.collect()\r\n 16\r\n 17 2685.7 MiB 0.0 MiB 2 print(\r\n 18 2685.7 MiB 0.0 MiB 2 \"current process memory: %.4f GB\"\r\n 19 2685.7 MiB 0.0 MiB 1 % (psutil.Process(os.getpid()).memory_info().rss / 1024 / 1024 / 1024),\r\n 20 )\r\n\r\n```","author":{"url":"https://github.com/joyme123","@type":"Person","name":"joyme123"},"datePublished":"2024-09-09T08:41:44Z","url":"https://github.com/python-openxml/python-docx/issues/1428"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:245de0dd-592e-7aad-7496-906103b176e3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A856:13328D:2A159B:383651:6AFF6595 |
| html-safe-nonce | ef4dd7e54774ec740ea1d459d4f44481fe4be83e049ea03df81cf76b0c5d7792 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODU2OjEzMzI4RDoyQTE1OUI6MzgzNjUxOjZBRkY2NTk1IiwidmlzaXRvcl9pZCI6IjU4NDEyNjgxMjU1MTI3MjE4MTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 51d48b73fb11dd1236472a18187edf6defe64bdf3ac1b82d8abd16a7f7df508c |
| hovercard-subject-tag | issue:2513312423 |
| 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/python-openxml/python-docx/1428/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8b6641143d01fc37691cc0e9240b6247d5d55cd23d8daa4486befd8cc1aeb214/python-openxml/python-docx/issues/1428 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8b6641143d01fc37691cc0e9240b6247d5d55cd23d8daa4486befd8cc1aeb214/python-openxml/python-docx/issues/1428 |
| og:image:alt | similar issue: #1364 reproduce code: import gc import os import psutil from docx import Document from memory_profiler import profile @profile def main(): file = "test.docx" document = Document(file... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | joyme123 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 41b58589a1c4eda1e3c8904144a412b88ca4455f63ca2ad3629f2e9f3c3a1d12 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-openxml/python-docx git https://github.com/python-openxml/python-docx.git |
| octolytics-dimension-user_id | 3403760 |
| octolytics-dimension-user_login | python-openxml |
| octolytics-dimension-repository_id | 13592924 |
| octolytics-dimension-repository_nwo | python-openxml/python-docx |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 13592924 |
| octolytics-dimension-repository_network_root_nwo | python-openxml/python-docx |
| 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 | 8968d6d6acc65d74e4df332d23932dd3fd0502a4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width