forked from 1b-agent/opencadstudio-upstream
The renderer shares one set of wire GPU buffers per wire_content_id across every pane and viewport slot. Every geometry edit mints a new content id, so every edit builds a new set -- and the old one stayed in wire_buffer_cache until the map exceeded sixteen entries. Sixteen entries is a sane bound for small drawings and fatal for large ones. The policy counted entries, not bytes. On the reproducer a single set is most of the card: the VRAM trace shows 572 MiB baseline rising to 1871 MiB on a 2048 MiB GT 1030. The second set has nowhere to go, so the first edit after opening exhausts VRAM. The perf log shows exactly that -- two `shared-fullupload` lines, an edit, then the process dies. Evict on every miss instead of at a count threshold, and do it before building the replacement rather than after, so the old allocation is released while the new one is still being sized. Dropping this slot's own handles first is what lets the retain see the superseded entry as garbage; a pane still drawing that content keeps its own clone and its strong count stays above one, so shared geometry is never pulled out from under a live viewport. The trade is that returning to a previous content id -- undo, mostly -- now rebuilds instead of hitting a warm entry. On a card where the alternative is dying, that is the right way round. Adds a PERF line reporting evicted and retained entry counts, so the policy can be watched rather than assumed. Co-Authored-By: Claude Opus 5 <[email protected]>