mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
free memory in cells LRU
This commit is contained in:
@ -315,7 +315,13 @@ pub fn deinit(self: *OpenGL) void {
|
|||||||
self.ebo.destroy();
|
self.ebo.destroy();
|
||||||
self.vao.destroy();
|
self.vao.destroy();
|
||||||
self.program.destroy();
|
self.program.destroy();
|
||||||
self.cells_lru.deinit(self.alloc);
|
|
||||||
|
{
|
||||||
|
// Our LRU values are array lists so we need to deallocate those first
|
||||||
|
while (self.cells_lru.queue.pop()) |node| node.data.value.deinit(self.alloc);
|
||||||
|
self.cells_lru.deinit(self.alloc);
|
||||||
|
}
|
||||||
|
|
||||||
self.cells.deinit(self.alloc);
|
self.cells.deinit(self.alloc);
|
||||||
self.* = undefined;
|
self.* = undefined;
|
||||||
}
|
}
|
||||||
@ -537,7 +543,6 @@ pub fn rebuildCells(self: *OpenGL, term: *Terminal) !void {
|
|||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the starting index for our row so we can cache any new GPU cells.
|
// Get the starting index for our row so we can cache any new GPU cells.
|
||||||
const start = self.cells.items.len;
|
const start = self.cells.items.len;
|
||||||
|
|
||||||
@ -557,7 +562,15 @@ pub fn rebuildCells(self: *OpenGL, term: *Terminal) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize our list
|
// Initialize our list
|
||||||
if (!gop.found_existing) gop.value_ptr.* = .{};
|
if (!gop.found_existing) {
|
||||||
|
gop.value_ptr.* = .{};
|
||||||
|
|
||||||
|
// If we evicted another value in our LRU for this one, free it
|
||||||
|
if (gop.evicted) |kv| {
|
||||||
|
var list = kv.value;
|
||||||
|
list.deinit(self.alloc);
|
||||||
|
}
|
||||||
|
}
|
||||||
var row_cells = gop.value_ptr;
|
var row_cells = gop.value_ptr;
|
||||||
|
|
||||||
// Get our new length and cache the cells.
|
// Get our new length and cache the cells.
|
||||||
|
Reference in New Issue
Block a user