Title: Potential memory leak in SimpleHeap's removed_node_tuples · Issue #71 · brean/python-pathfinding · GitHub
Open Graph Title: Potential memory leak in SimpleHeap's removed_node_tuples · Issue #71 · brean/python-pathfinding
X Title: Potential memory leak in SimpleHeap's removed_node_tuples · Issue #71 · brean/python-pathfinding
Description: Hey there, I've been investigating a memory issue in the SimpleHeap implementation and found that removed_node_tuples can grow indefinitely during pathfinding, especially on larger grids. The problem is that when nodes are "removed" via ...
Open Graph Description: Hey there, I've been investigating a memory issue in the SimpleHeap implementation and found that removed_node_tuples can grow indefinitely during pathfinding, especially on larger grids. The probl...
X Description: Hey there, I've been investigating a memory issue in the SimpleHeap implementation and found that removed_node_tuples can grow indefinitely during pathfinding, especially on larger grids. The p...
Opengraph URL: https://github.com/brean/python-pathfinding/issues/71
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Potential memory leak in SimpleHeap's removed_node_tuples","articleBody":"Hey there, I've been investigating a memory issue in the SimpleHeap implementation and found that `removed_node_tuples` can grow indefinitely during pathfinding, especially on larger grids.\n\nThe problem is that when nodes are \"removed\" via `remove_node()`, they get added to `removed_node_tuples` but are never cleaned up. Over time, this set just keeps growing.\n\nAfter digging into the code, I'm wondering if `removed_node_tuples` is actually necessary at all? From what I can see, the A* algorithm already marks processed nodes with the closed flag, so we could potentially simplify things by:\n\n1. Getting rid of `removed_node_tuples` completely\n2. Having `pop_node()` just skip any nodes that are already closed\n3. Making `remove_node()` do nothing (or removing it entirely)\n\nSomething like:\n```\ndef pop_node(self):\n while self.open_list:\n node_tuple = heapq.heappop(self.open_list)\n # ... get node from tuple ...\n if not node.closed:\n return node\n return None\n```\n\nI tested this approach and it seems to work correctly while eliminating the memory leak. The pathfinding results are identical, but without the growing memory usage.\n\nIs there a specific reason removed_node_tuples was implemented this way, or would you be interested in a PR that simplifies this? I might be missing some edge case that requires the current approach, so wanted to check first.\n\nThanks!","author":{"url":"https://github.com/codelion","@type":"Person","name":"codelion"},"datePublished":"2025-08-15T01:27:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/71/python-pathfinding/issues/71"}
| 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:a8fb55f9-9e23-d04e-cd0d-0ff9c22a5f6b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 95AA:D6EC3:60C35A:7D06A1:698D2368 |
| html-safe-nonce | 35e4c9b68fa82bd9275ce30fad5af8b623de2dc4607c77c2b7a60ca260316cc0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NUFBOkQ2RUMzOjYwQzM1QTo3RDA2QTE6Njk4RDIzNjgiLCJ2aXNpdG9yX2lkIjoiODA1NzAyMTYzMTU3MzA3NDc5MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8d7db386cc279d8aec086bcdb3519c6749aa8c48719977aece0ee3957e25af15 |
| hovercard-subject-tag | issue:3324056333 |
| 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/brean/python-pathfinding/71/issue_layout |
| twitter:image | https://opengraph.githubassets.com/573f4db41e8b4870734bd0f8008059da025c74174b195e8bd0716b35673e3608/brean/python-pathfinding/issues/71 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/573f4db41e8b4870734bd0f8008059da025c74174b195e8bd0716b35673e3608/brean/python-pathfinding/issues/71 |
| og:image:alt | Hey there, I've been investigating a memory issue in the SimpleHeap implementation and found that removed_node_tuples can grow indefinitely during pathfinding, especially on larger grids. The probl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | codelion |
| hostname | github.com |
| expected-hostname | github.com |
| None | c25395580e1e3bf82d705e0982a1b24255366088720fef945f1493d5e3e67954 |
| turbo-cache-control | no-preview |
| go-import | github.com/brean/python-pathfinding git https://github.com/brean/python-pathfinding.git |
| octolytics-dimension-user_id | 229768 |
| octolytics-dimension-user_login | brean |
| octolytics-dimension-repository_id | 32716626 |
| octolytics-dimension-repository_nwo | brean/python-pathfinding |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 32716626 |
| octolytics-dimension-repository_network_root_nwo | brean/python-pathfinding |
| 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 | 94219dcb9c044792ec271fd5b23c73419858bef7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width