Frontmatter
| id | 9468 |
| title | Fix memory leak in TreeStore.#rebuildKeysAndCount() |
| state | Closed |
| labels | bugai |
| assignees | tobiu |
| createdAt | Mar 13, 2026, 4:12 PM |
| updatedAt | Mar 13, 2026, 4:19 PM |
| githubUrl | https://github.com/neomjs/neo/issues/9468 |
| author | tobiu |
| commentsCount | 0 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| contentTrust | |
| projected | |
| quarantined | 0 |
| signals | [] |
| blockedBy | [] |
| blocking | [] |
| closedAt | Mar 13, 2026, 4:19 PM |
Bug Description
In
TreeStore.#rebuildKeysAndCount(), an array_keysis allocated and assigned to the store instance (me._keys = new Array(len)). This array is only used locally within this method to populate the internalmapand is never read or used anywhere else in theCollectionorTreeStorelifecycle. Because it is bound to the instance, it persists indefinitely, causing an unnecessary memory leak that grows with every bulk projection (likeexpandAllorfilter).Solution
Remove the assignment to
me._keysand use a local variable instead to prevent the memory leak.#rebuildKeysAndCount() { let me = this, items = me._items, len = items.length, keys = new Array(len), {map} = me; map.clear(); for (let i = 0; i < len; i++) { let key = me.getKey(items[i]); keys[i] = key; map.set(key, items[i]) } me.count = len }