Entry 622
What the game and the launcher hold, and an event stream's set-up made smaller
Linked from The launcher's build in a process of its own.
Files8 in 6 directories
Mentioned incrates/piney-game/src/session/tests/survey.rs:4195
A player on Windows 11 (16 GB) saw piney-apples at 45.1% of memory in Task Manager, about three times Edge, with Mutation in a town and the Party menu open, shortly after trying the new launcher. Measured on Linux in one process across many areas, nothing in the game grows: no leak, no cache without bound, and the GPU heap stays in its first two blocks. What is big is a launcher that has built the discs (it keeps the build's freed memory, some 750 MB) and a transient of about 500 MB while an event stream sets up in a town. The second is cut down here; the first wants the build in a child process, which is left for a decision.
How it was measured
- Many areas in one process.
session::tests::survey::memory_over_a_long_run(ignored) plays Mutation from event 101 under the story autopilot (god, the cores, the boss levels), every frame drawn by a headless GS and every event routed into a headless audio engine, and prints the resident and peak memory with the GS's holdings at each change of place, each 1000 frames, and whenever the resident moves 30 MB. 150,000 frames (42 minutes of play) took it through 46 changes of place: the desktop and top page 24 times, Dun Loireag 5, Carmina Gadelica 7, fields 2, 27, 43, 44, 45 and 46 and the dungeons under them, battles, streams. - The window. A nested
kwin_wayland --virtualwith its own Xwayland, DBus, runtime folder and home (env -i), keys by xdotool to that Xwayland only: the launcher idle, Play, the game running, and the launcher through a rebuild at start (a stale stamp). - Attribution. A small LD_PRELOAD logger of allocations of 24 MB or more
with their backtraces, symbolised with addr2line; glibc's
malloc_statsandmalloc_trimcalled through gdb on the launcher it started. - Logs. The real
piney-gamea minute (3600 frames) in each ofworld,field:27,dungeon:27,story:101andstory:104, and the launcher's game log over four minutes of play.
The game's renderer
| frame | resident | peak | file textures | GPU heap |
|---|---|---|---|---|
| 10,000 | 516 MB | 614 MB | 180 | 89 MB in 192 MB |
| 20,000 | 557 MB | 614 MB | 265 | 86 MB in 192 MB |
| 50,000 | 640 MB | 1,199 MB | 97 | 47 MB in 192 MB |
| 90,000 | 623 MB | 1,199 MB | ||
| 150,000 | 623 MB | 1,199 MB | 48 | 49 MB in 192 MB |
- Flat. From 50,000 frames on the resident stays at 620-640 MB. The GS
holds 48 to 133 file textures and 5 to 14 MB of
DATA.BINfiles: both are dropped whenever a stream's overlay comes or goes (Gs::set_overlay), so neither builds up across areas. - The GPU heap. wgpu-hal 30 suballocates with gpu-allocator on Vulkan
and DX12 alike,
MemoryHints::Performanceby default: a 128 MB device block and a 64 MB host block. The game allocates 40 to 90 MB in them and never asks for a third. The newmemory_says_what_is_heldtest draws 220 frames each with a new 640 x 448 movie picture: the heap's allocations and blocks after 220 are no more than after 20. - Sized by settings. The frame buffer is the GS's 512 x 448 times the render scale (1 by default, at most 8: 4096 x 3584, 117 MB with its Z); frame-buffer copies are this frame's only. The window's size reaches only the swapchain, which the driver keeps.
- The window. Mutation from the launcher, 240 s on the title and the save screens: 393 MB resident, 227 MB anonymous, flat. The window in Dun Loireag: 448 MB resident, 247 MB anonymous.
- The backend. wgpu-core lists Vulkan, Metal, DX12 and GL in that order
and sorts by device type only (discrete first for HighPerformance), so on
Windows the game takes Vulkan wherever the driver has it, DX12 otherwise.
Release builds run without validation. The game now logs the adapter at
start (
gpu: NVIDIA GeForce RTX 5090 (Vulkan, DiscreteGpu, NVIDIA 620.70.06)).
The stream transient
The peak is not growth: it comes and goes in 40 frames whenever an event's
stream sets up while a town loads (loading 1, the event pass at phase 0).
Into Dun Loireag at frame 26,719 the resident went 610, 836, 1,100, 1,174
and back to 616 MB. The large allocations, in order:
piney_stream::load::read_in: the stream's gzip members off the disc, 38 and 56 MB;load::archive: the same bytes copied into one buffer grown by doubling to 158 MB, whileStreamwent on holding the members' own copies too;Archive::inflate: each scene's CCSF file inflated byread_to_end, its buffer grown to 134 MB twice and kept at that capacity;piney_data::texture::read: 33 MB vectors walking the scene's textures.
The fixes keep the picture and the sound as they were (the bytes read are the same):
load::archivesizes its buffer from the members first;Streamkeeps each member as aload::Placed(its record and stem), its bytes being the archive's, not a second copy for the stream's length;Archive::inflateshrinks the buffer to the file before handing it on, for every caller (the GS's assets, the streams, the areas).
| before | after | |
|---|---|---|
| field 27's stream, peak | 871 MB | 764 MB |
| Dun Loireag's stream, peak | 1,193 MB | 1,070 MB |
| resident at frame 27,000 | 616 MB | 563 MB |
What stays is the game's own data held as the port reads it: a scene of 70 MB or more inflated whole, where the PS2 streams it through 32 MB. Streaming the scene is the bound beyond this, and an architectural change.
The launcher's renderer
- Idle on the Library: 307 to 365 MB resident, 80 MB anonymous. The rest
is the GPU driver's files (NVIDIA's GL, Vulkan and EGL cores, Mesa's
libgallium and libLLVM) that
report::gpu_lineand GPUI load; the instancegpu_linemakes on a thread is dropped when it returns, after it has started every backend once (Vulkan, DX12 and GL on Windows). - While a game runs: 311 MB resident, 80.6 MB anonymous, flat over 240 s.
The 150 ms ticker calls
cx.notify()only when something changed, the fonts are added once at start, and the launcher draws no images. - After a build in the window: 1,060 MB resident, 825 MB anonymous, flat
30 s on.
malloc_statsthen: 824 MB held by malloc, 72 MB in use; the build thread's arena alone held 453 MB.malloc_trim(0)brought it to 587 MB resident. So it is not a leak but glibc keeping the build's freed memory for a thread that has ended. A player who builds and then plays carries it for the whole session. The fix is the build in a child process, as the game already is; it is not made here (an architectural change tojob.rs, its progress and its cancel), and is reported with these numbers. - The Help page's log tail.
facts()ran on every redraw of the Help page andlogs::last_linesread the whole newest log into lines to take its last 40. It now reads from the end in 16 KiB steps until it has the lines (the_tail_of_a_long_logchecks it against reading all of a 20,000-line log, at either end of a step, with and without a last newline).
Log spam
There is none to stop. The game's log a minute: world 688 bytes,
field:27 187, dungeon:27 189, story:101 169, story:104 202; four
minutes of the windowed game from the launcher, 291 bytes. The event host: ... is not ported warnings are four lines at start (busy,
name_entry_step, grunty_mail, story_area), each once:
piney_event::host::unported already keeps the names it warned of.
Windows
Task Manager's Processes tab shows each process's active private working set, and a row that groups the launcher and the game it started adds them; the 45.1% is what the column's header shows, the whole system's memory in use, unless the view was switched to percentages. GPU memory in a card's own VRAM is not in the private working set. On Linux the two together come to about 1,100 MB anonymous after a build (825 + 250); nothing measured here reaches 7 GB.
For the next report the game's console has memory (README, Reporting a
bug): the process's memory where the system says it (Linux), the adapter,
and Gs::memory: the file textures, uploads and their bytes, the frame
buffer, the vertex buffers, the files read, and the GPU heap's allocations,
bytes and blocks.
Checks
- Crate tests (
cargo test --workspace --exclude piney-game): 831 pass (829 andthe_tail_of_a_long_log,memory_says_what_is_held), 0 fail, 1 ignored. - The piney-game suite (
cargo test -p piney-game --release): 364 / 0 / 154 (the new ignored diagnostic;tab_completes_the_commandslistsmemory). - Clippy (workspace, all targets and features,
-D warnings) and fmt clean. - The golden shots (
shots.sh mem-622againstbase): 4,550 files, 0 differ. tools/test_stream_rs.py tableson Mutation and Outbreak writes its fixtures unchanged; the stream crate's tests read them and the disc.- The window's console
memory, from a replayed pad log in Dun Loireag:process: resident 448 MB (247 MB anonymous), thegpu:line, andgs: 47 file textures, 2 uploads (8.7 MB), frame buffer 1.8 MB, vertices 16.0 MB, 4 pipelines; 17 files read (5.7 MB); gpu heap 62 allocations, 27.8 MB in 2 blocks of 192.0 MB.
what the player's Task Manager figure was (the header's
system-wide percentage or the row's private working set), which backend and
adapter their game took, and whether Windows' heap keeps the in-launcher
build's freed memory as glibc does. No code here can answer them; the
memory console line and the gpu: log line from that machine will. Moving
the build to a child process waits for the maintainer's word.