forked from mirror/vulkan-zig
example: really resolve swapchain memory leak this time
This commit is contained in:
@@ -101,6 +101,7 @@ pub const Swapchain = struct {
|
||||
|
||||
fn deinitExceptSwapchain(self: Swapchain) void {
|
||||
for (self.swap_images) |si| si.deinit(self.gc);
|
||||
self.allocator.free(self.swap_images);
|
||||
self.gc.vkd.destroySemaphore(self.gc.dev, self.next_image_acquired, null);
|
||||
}
|
||||
|
||||
@@ -110,7 +111,6 @@ pub const Swapchain = struct {
|
||||
|
||||
pub fn deinit(self: Swapchain) void {
|
||||
self.deinitExceptSwapchain();
|
||||
self.allocator.free(self.swap_images);
|
||||
self.gc.vkd.destroySwapchainKHR(self.gc.dev, self.handle, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,9 @@ pub fn main() !void {
|
||||
) orelse return error.WindowInitFailed;
|
||||
defer c.glfwDestroyWindow(window);
|
||||
|
||||
const allocator = std.heap.page_allocator;
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
defer _ = gpa.deinit();
|
||||
const allocator = gpa.allocator();
|
||||
|
||||
const gc = try GraphicsContext.init(allocator, app_name, window);
|
||||
defer gc.deinit();
|
||||
|
||||
Reference in New Issue
Block a user