Skip to content

fix: ModuleModel never frees its tree - #675

Merged
joern274 merged 1 commit into
emsec:masterfrom
horhulenko:fix/module-model-leak
Oct 27, 2026
Merged

joern274 merged 1 commit into
emsec:masterfrom
horhulenko:fix/module-model-leak

Conversation

@horhulenko

Copy link
Copy Markdown
Contributor

ModuleModel had no destructor, so when one was destroyed, its root item and every item under it stayed in memory. On master, this happens every time the content of a grouping is shown and closed.

The fix deletes the root item in ~ModuleModel, the same way GatePinsTreeModel and ModulePinsTreeModel already do. It can't go into BaseTreeModel: ModuleItem removes itself from the model's maps when it's deleted, and those maps would already be gone by then.

Memory left after showing and closing the content of 50 groupings of 1000 gates, 4 times in a row:

round 1 round 2 round 3 round 4
before +10.7 MB +21.4 MB +32.1 MB +42.7 MB
after +0 MB +0 MB +0 MB +0 MB

@joern274 joern274 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great fix but unnecessary complicated CHANGELOG entry. Better : fixed memory leak in ModuleModel base class.

@joern274
joern274 merged commit 1024c97 into emsec:master Oct 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants