diff options
Diffstat (limited to 'src/File.zig')
| -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. |
