Skip to content

Unknown memory leakage. #79

@oddman621

Description

@oddman621

[Environment]
Windows 11 x64
Zig 0.15.2
GLFW with OpenGL 3

[Code]

// build.zig
const std = @import("std");

pub fn build(b: *std.Build) void {
    // ...
    const zgui = b.dependency("zgui", .{
        .shared = false,
        .backend = @import("zgui").Backend.glfw_opengl3,
    });
    // ...
}
// main.zig
const std = @import("std");
const gl = @import("zgl");
const glfw = @import("zglfw");
const zgui = @import("zgui");

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    defer _ = gpa.deinit();
    const allocator = gpa.allocator();

    try glfw.init();
    const window = try glfw.createWindow(640, 480, "Test Zgui Init", null);
    glfw.makeContextCurrent(window);
    glfw.swapInterval(1);
    try gl.loadExtensions(null, getProcAddr);
    zgui.init(allocator);
    zgui.backend.init(window);

    // deinit without 'defer'
    zgui.backend.deinit();
    zgui.deinit();
    glfw.destroyWindow(window);
    glfw.terminate();
}

fn getProcAddr(_: anytype, proc_name: [:0]const u8) ?*const anyopaque {
    return glfw.getProcAddress(proc_name);
}

[Result]

> zig build run
info: [zgui] Possible memory leak or static memory usage detected: (address: 0x25be45f0000, size: 128)

Where does this leak come from, even didn't do anything with zgui except init/deinit?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions