mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
remove memory pool usage for mac
This commit is contained in:
10
src/App.zig
10
src/App.zig
@ -23,7 +23,6 @@ const DevMode = @import("DevMode.zig");
|
||||
const log = std.log.scoped(.app);
|
||||
|
||||
const SurfaceList = std.ArrayListUnmanaged(*apprt.Surface);
|
||||
const SurfacePool = std.heap.MemoryPool(apprt.Surface);
|
||||
|
||||
/// The type used for sending messages to the app thread.
|
||||
pub const Mailbox = BlockingQueue(Message, 64);
|
||||
@ -34,12 +33,6 @@ alloc: Allocator,
|
||||
/// The list of surfaces that are currently active.
|
||||
surfaces: SurfaceList,
|
||||
|
||||
/// The memory pool to request surfaces. We use a memory pool because surfaces
|
||||
/// typically require stable pointers due to runtime GUI callbacks. Centralizing
|
||||
/// all the allocations in this pool makes it so that all our pools remain
|
||||
/// close in memory.
|
||||
surface_pool: SurfacePool,
|
||||
|
||||
// The configuration for the app.
|
||||
config: *const Config,
|
||||
|
||||
@ -72,13 +65,11 @@ pub fn create(
|
||||
app.* = .{
|
||||
.alloc = alloc,
|
||||
.surfaces = .{},
|
||||
.surface_pool = try SurfacePool.initPreheated(alloc, 2),
|
||||
.config = config,
|
||||
.mailbox = mailbox,
|
||||
.quit = false,
|
||||
};
|
||||
errdefer app.surfaces.deinit(alloc);
|
||||
errdefer app.surface_pool.deinit();
|
||||
|
||||
return app;
|
||||
}
|
||||
@ -87,7 +78,6 @@ pub fn destroy(self: *App) void {
|
||||
// Clean up all our surfaces
|
||||
for (self.surfaces.items) |surface| surface.deinit();
|
||||
self.surfaces.deinit(self.alloc);
|
||||
self.surface_pool.deinit();
|
||||
self.mailbox.destroy(self.alloc);
|
||||
|
||||
self.alloc.destroy(self);
|
||||
|
@ -78,8 +78,8 @@ pub const App = struct {
|
||||
/// Create a new window for the app.
|
||||
pub fn newWindow(self: *App) !*Surface {
|
||||
// Grab a surface allocation because we're going to need it.
|
||||
const surface = try self.app.surface_pool.create();
|
||||
errdefer self.app.surface_pool.destroy(surface);
|
||||
var surface = try self.app.alloc.create(Surface);
|
||||
errdefer self.app.alloc.destroy(surface);
|
||||
|
||||
// Create the surface -- because windows are surfaces for glfw.
|
||||
try surface.init(self);
|
||||
@ -125,7 +125,7 @@ pub const App = struct {
|
||||
/// Close the given surface.
|
||||
pub fn closeSurface(self: *App, surface: *Surface) void {
|
||||
surface.deinit();
|
||||
self.app.surface_pool.destroy(surface);
|
||||
self.app.alloc.destroy(surface);
|
||||
}
|
||||
|
||||
fn glfwErrorCallback(code: glfw.ErrorCode, desc: [:0]const u8) void {
|
||||
|
Reference in New Issue
Block a user