diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 12:01:17 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 13:14:28 -0300 |
| commit | 7ff2368427c2c11488ead052f2fc7f1dd3ff6143 (patch) | |
| tree | ffb02475f826323cb3e86dd8b36df1304c33953a | |
| parent | ffd67bb16e9080a9f06cf4726000ec3b0bfa07df (diff) | |
| download | pardes-7ff2368427c2c11488ead052f2fc7f1dd3ff6143.tar.gz pardes-7ff2368427c2c11488ead052f2fc7f1dd3ff6143.zip | |
text journal, a grown text's old buffer given back: a text whose room grows by a copy frees a buffer of a megabyte or more, which an arena keeps resident for the next block its size; memory.trim gives its pages back at once, as a big pane torn down does (a detached session on a 100 MB file, Debug: after typing, twelve 9P edits, undo, redo and a 10 MB cut, 157-166 MB resident where the journal alone left 329 and the snapshots 730; the peak while the copy is made, 328 MB, stays)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
| -rw-r--r-- | src/File.zig | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/File.zig b/src/File.zig index 8f3d4bb9..4b73b311 100644 --- a/src/File.zig +++ b/src/File.zig @@ -1004,6 +1004,10 @@ fn grow(gpa: std.mem.Allocator, f: *State, n: usize) !void { pardes.memory.freeRaw(gpa, room); f.content = fresh[0..f.content.len]; f.cap = fresh.len; + // The old buffer's pages back to the system now: an arena keeps a freed + // run of a megabyte or more resident for the next block its size, which + // a text grown with room never asks for (a 100 MB file held its copy). + if (room.len >= 1 << 20) pardes.memory.trim(); } /// `text` with the `len` bytes at `off` replaced by `bytes`, in a new buffer. |
