Skip to content

gc: per-frame memory-pressure detection + heap pinning + with_await fix#195

Merged
borisbat merged 2 commits into
masterfrom
bbatkin/imgui-gc-pressure
Jun 8, 2026
Merged

gc: per-frame memory-pressure detection + heap pinning + with_await fix#195
borisbat merged 2 commits into
masterfrom
bbatkin/imgui-gc-pressure

Conversation

@borisbat

@borisbat borisbat commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Adds an opt-in tool to see per-frame GC pressure in imgui apps, pins the collectable heap, and fixes one per-command leak. Pairs with the daslang json PR (GaijinEntertainment/daScript#3034), which does the heavy lifting (frees dispatched snapshot trees, ?[] sentinel) — with_await here uses the new update() from that PR, so merge #3034 first.

Detection mode (imgui_boost_runtime)

Ported from strudel_player's heap-delta tracking:

  • imgui_debug_memory(enabled) / imgui_reset_memory_baseline() / imgui_memory_report() — baseline + running max + a periodic per-frame line of heap / string-heap usage, gated behind a flag. Off by default — one bool test per frame when off.
  • sample_memory() runs once per frame from begin_frame() (the universal per-frame reset); a teardown summary fires from harness_shutdown(), with a WARNING if heap or string-heap grew past 64 kb since baseline.
  • imgui_memory_debug live-command (in imgui_visual_aids, the debug-toggle home) so the recorder / MCP can flip it remotely.

with_await leak fix

Rewritten to add the await modifiers onto the result object in place via the new update(), instead of copying every field into a fresh table and returning that — which orphaned the original JV(payload) wrapper on every await-wrapped command.

Heap pinning

options persistent_heap on imgui_boost_runtime + imgui_harness (collectable heap so per-frame JsonValue churn is reclaimed by delete + GC; runtime options unify program-wide).

Verification

  • Live buttons.das run with imgui_memory_debug on: the steady heap held flat at ~0x21 kb across 5500+ frames, including the heavy imgui_snapshot dispatches at frames 2779/4856 — max briefly ticked to 0x26 kb on a snapshot then the steady heap returned, i.e. the ~40-widget tree is built and freed (the formerly-leaking path).
  • Full integration suite: 171 passed headless; the 13 GLFW-backend synth tests (which need a real window) confirmed passing windowed — no regression.
  • All changed files lint + format clean.

🤖 Generated with Claude Code

borisbat and others added 2 commits June 7, 2026 12:51
Detection mode (imgui_boost_runtime), ported from strudel_player's heap-delta
tracking:
- imgui_debug_memory(enabled) / imgui_reset_memory_baseline() /
  imgui_memory_report(): baseline + running max + a periodic per-frame log of
  heap / string-heap usage, gated behind a flag (one bool test per frame when off).
- sample_memory() runs once per frame from begin_frame (the universal per-frame
  reset); teardown summary in harness_shutdown (+ a WARNING if heap/str grew past
  64kb since baseline).
- imgui_memory_debug live-command (visual_aids) so the recorder / MCP can toggle
  it remotely.

with_await: add the await modifiers onto the result object in place via the new
json update() helper, instead of copying every field into a fresh table and
orphaning the original wrapper each call.

options persistent_heap on imgui_boost_runtime + imgui_harness (collectable heap
so per-frame JsonValue churn is reclaimed by delete + GC; runtime options unify
program-wide).

Depends on the json delete_json/update/json_null_sentinel helpers (daslang PR).

Verified on a live buttons.das run: with imgui_memory_debug on, the steady heap
held flat at ~0x21kb across 5500+ frames including snapshot dispatches (the
formerly-leaking path); full integration suite shows no regression.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The GC-pressure detection work added imgui_debug_memory /
imgui_reset_memory_baseline / imgui_memory_report (imgui_boost_runtime)
and the imgui_memory_debug live command (imgui_visual_aids). Add a
"Memory debugging" group_by_regex for each module so they are categorized
instead of tripping the Uncategorized doc gate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@borisbat borisbat merged commit 14220f7 into master Jun 8, 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.

1 participant