Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The file generated by running 'build' consumes more memory than 'zig build run' #19739

Open
updoo opened this issue Apr 22, 2024 · 2 comments
Open
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@updoo
Copy link

updoo commented Apr 22, 2024

Zig Version

0.12.0

Steps to Reproduce and Observed Behavior

example from github.com:zigzap/zap

const std = @import("std");
const zap = @import("zap");

fn on_request(r: zap.Request) void {
    r.sendBody("Hello, World!") catch return;
}

pub fn main() !void {
    var listener = zap.HttpListener.init(.{
        .port = 3000,
        .on_request = on_request,
        .log = false,
    });
    try listener.listen();

    std.debug.print("Listening on 0.0.0.0:3000\n", .{});

    // start worker threads
    zap.start(.{
        .threads = 3,
        .workers = 3,
    });
}

run on mac m1

# step 1:  run with 'zig build run', using 3MB of memory
zig build run

# step 2: run binary generated by 'zig build',using 22MB of memory
zig build
./zig-out/bin/hello

Expected Behavior

Memory usage should be consistent

@updoo updoo added the bug Observed behavior contradicts documented or intended behavior label Apr 22, 2024
@Vexu
Copy link
Member

Vexu commented Apr 22, 2024

What's in your build.zig?

@mlugg
Copy link
Member

mlugg commented Apr 22, 2024

Also, how are you measuring memory consumption? The peak RSS of the zig build run command won't include the memory usage of your application, because it's a subprocess.

In general, the "Steps to Reproduce" section should include exact steps, i.e. the precise commands / applications that were run and the relevant output to observe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

3 participants