mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
Free up cells memory on resize
This commit is contained in:
@ -1784,6 +1784,15 @@ pub fn rebuildCells(
|
||||
}
|
||||
}
|
||||
|
||||
// Free up memory, generally in case where surface has shrunk.
|
||||
// If more than half of the capacity is unused, remove all unused capacity.
|
||||
if (self.cells.items.len * 2 < self.cells.capacity) {
|
||||
self.cells.shrinkAndFree(self.alloc, self.cells.items.len);
|
||||
}
|
||||
if (self.cells_bg.items.len * 2 < self.cells_bg.capacity) {
|
||||
self.cells_bg.shrinkAndFree(self.alloc, self.cells_bg.items.len);
|
||||
}
|
||||
|
||||
// Some debug mode safety checks
|
||||
if (std.debug.runtime_safety) {
|
||||
for (self.cells_bg.items) |cell| assert(cell.mode == .bg);
|
||||
|
Reference in New Issue
Block a user