Title: context/data: memleak due to API (mis)use by bradh352 · Pull Request #131 · CESNET/libyang-python · GitHub
Open Graph Title: context/data: memleak due to API (mis)use by bradh352 · Pull Request #131 · CESNET/libyang-python
X Title: context/data: memleak due to API (mis)use by bradh352 · Pull Request #131 · CESNET/libyang-python
Description: Memory management is a foreign concept to python in general, however it appears DNode and Context require .free() and .destroy() to be called, respectively, to avoid a memory leak. This seems easily avoidable by simply attaching a destructor to the class so the python garbage collector can clean up automatically when all references go out of scope. We add a reference to any DNode object derived from another DNode object (but not duplicated) so we can determine if we are allowed to be the one to destroy the DNode cdata, as well as to keep proper reference counting in case the owner goes out of scope but a dependent reference is still in scope. This change should also be compatible with existing integrations which may be aware of this as it sets the internal cdata reference to None and checks it to ensure it doesn't run the cleanup again. That said, I think calling DNode.free() in this case is still risky since there are no checks to ensure this is truly valid like the destructor does. Signed-off-by: Brad House (@bradh352)
Open Graph Description: Memory management is a foreign concept to python in general, however it appears DNode and Context require .free() and .destroy() to be called, respectively, to avoid a memory leak. This seems easil...
X Description: Memory management is a foreign concept to python in general, however it appears DNode and Context require .free() and .destroy() to be called, respectively, to avoid a memory leak. This seems easil...
Opengraph URL: https://github.com/CESNET/libyang-python/pull/131
X: @github
Domain: patch-diff.githubusercontent.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:9a37d581-a8ba-3948-ed7b-f1e889933cec |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | A428:F1E4C:204C4A:2BEF57:698E2AF6 |
| html-safe-nonce | e763877aa9833539103bc47ccef5a58c651535cd34b443cc10ed1ab4b8fb42bb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDI4OkYxRTRDOjIwNEM0QToyQkVGNTc6Njk4RTJBRjYiLCJ2aXNpdG9yX2lkIjoiNTI1MTU4NDI3Njk4MjI3ODkwMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 34227db823b201a1fee8feea4b5bb93a5fa79028c37500517aaac1cf16ede03d |
| hovercard-subject-tag | pull_request:2319998081 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,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/CESNET/libyang-python/pull/131/checks |
| twitter:image | https://avatars.githubusercontent.com/u/19732188?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/19732188?s=400&v=4 |
| og:image:alt | Memory management is a foreign concept to python in general, however it appears DNode and Context require .free() and .destroy() to be called, respectively, to avoid a memory leak. This seems easil... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | a5632af64f7fed7bff1d6a428d1aca1b94fa7a48f760de2d39d9b1effdbf0082 |
| turbo-cache-control | no-cache |
| go-import | github.com/CESNET/libyang-python git https://github.com/CESNET/libyang-python.git |
| octolytics-dimension-user_id | 1116469 |
| octolytics-dimension-user_login | CESNET |
| octolytics-dimension-repository_id | 275748507 |
| octolytics-dimension-repository_nwo | CESNET/libyang-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 275748507 |
| octolytics-dimension-repository_network_root_nwo | CESNET/libyang-python |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2f1e729d231ea1ea5a098d21f1491b75bea53631 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width