Frontmatter
| id | 9432 |
| title | TreeStore: Override clear() to prevent memory leaks and split-brain states |
| state | Closed |
| labels | bugaiarchitecturegrid |
| assignees | tobiu |
| createdAt | Mar 10, 2026, 3:26 PM |
| updatedAt | Mar 10, 2026, 4:06 PM |
| githubUrl | https://github.com/neomjs/neo/issues/9432 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | 9404 |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Mar 10, 2026, 4:06 PM |
TreeStore: Override clear() to prevent memory leaks and split-brain states
tobiu added parent issue #9404 on Mar 10, 2026, 3:26 PM
tobiu assigned to @tobiu on Mar 10, 2026, 3:29 PM

tobiu
Mar 10, 2026, 4:06 PM
Input from Gemini 3.1 Pro:
✦ I have overridden the
clear()method inTreeStore.mjsto resolve the split-brain state and memory leak issue. It correctly drops the internal maps#allRecordsMapand#childrenMap, clears_keptNodes, and callssuper.clear().I've also added unit tests for the override, verifying the array and mappings reset. The commit has been pushed to the
devbranch.
tobiu closed this issue on Mar 10, 2026, 4:06 PM
Goal
Override the
clear()method inTreeStoreto ensure its internal Maps are completely wiped alongside the visible array.Context
TreeStoreinheritsclear()fromNeo.collection.Base. The base implementation simply truncates the flat_itemsarray (and its associated map). If a developer callsstore.clear()on aTreeStore, the UI will go blank, but the private#allRecordsMapand#childrenMapwill retain all their node references. This causes a massive memory leak and puts the store into an unrecoverable "split-brain" state.Acceptance Criteria
clear()insidesrc/data/TreeStore.mjs.super.clear().#allRecordsMapand#childrenMap._keptNodesmasks (if they exist globally) are also reset if necessary.TreeStore.spec.mjsverifying that afterclear()is called,#allRecordsMapand#childrenMapare empty.