[Bug] Every `#layout load` leaves the previous layout in memory

Open
#469 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 5 days

@syntaki is already working on this.

Since Dec 1, 2026.

  • #470 by @syntaki — open

Assessment

This issue has not been assessed yet.

Description

What happened

Genie's memory goes up each time a layout is loaded and does not come back down. With text in the windows the step is large: about 45 MB a load with 2,000 lines in each of two windows, and more for the first load.

A script that loads a layout when it starts adds that much at every start, so a window that runs all day keeps growing.

What you expected

About the same memory after a layout load as before it, since the same windows with the same text are on screen.

Steps to reproduce

  1. Start Genie. No connection is needed.
  2. Put text in two windows. I used fill.cmd below, which echoes 2,000 lines into the game window and 2,000 into Thoughts.
  3. Type #layout save global memtest.
  4. Note the memory of the Genie5 process, then type #layout load memtest five times, noting it after each.

RssAnon from /proc/PID/status:

MB
after filling the windows 278
after load 1 394
after load 2 441
after load 3 489
after load 4 532
after load 5 574
30 seconds later 558

fill.cmd, ten lines to each window per pass, 200 passes:

var n 0
loop:
math n add 1
put #echo [%n.0] You swing a heavy sword at a rock troll. A rock troll attempts to dodge, but fails. The sword lands a solid hit to the troll's left arm.
put #echo >Thoughts [%n.0] Your mind hears someone thinking, "anyone selling a decent set of plate armor near the crossing bank today?"
(the same two lines nine more times, numbered .1 to .9)
pause 0.05
if %n < 200 then goto loop
put #echo FILL DONE

Environment

  • OS + version: Ubuntu 26.04
  • Genie 5 version: 5.0.1-beta.5
  • Install type: AppImage
  • Connection mode: not connected (the steps need no connection)

Logs / session capture

FILL DONE
[script] fill done
[layout] saved 'memtest' (global)
[layout] loaded 'memtest' (global)
[layout] loaded 'memtest' (global)
[layout] loaded 'memtest' (global)
[layout] loaded 'memtest' (global)
[layout] loaded 'memtest' (global)

The loads themselves work. Nothing is printed about memory.

Anything else

Cause, as far as I can read it:

  • Controls/FindInWindow.cs adds a handler to the tool's FindInWindowModel each time a text window's view is built (model.PropertyChanged += … for the find box, model.JumpRequested += … for the scroller) and never removes it.
  • The model belongs to the tool and outlives the view. After a layout load it still holds the old find box and the old scroller, and through their parents the whole previous layout with its lines.
  • I assume a float or a re-dock does the same, since those rebuild the view too. I only measured layout loads.

The same is true of main as of d1373a5.

Workaround: none that I know of, other than loading a layout less often. Restarting Genie gives the memory back.

I have a fix with tests (the find box and the scroller listen to the model only while they are in a window), and a pull request follows.

Dominant language
C#
Stars
2
Forks
5
Avg merge
4d 3h
Merged PRs (30d)
22

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from GenieClient/Genie5

All issues in GenieClient/Genie5

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.