mirror of
https://github.com/ziglang/zig.git
synced 2025-12-29 01:23:17 +00:00
Implemented getMaxRss for Windows
In Windows, the equivalent to maxrss is PeakWorkingSetSize which is found in PROCESS_MEMORY_COUNTERS in bytes. Currently, this is done by calling `GetProcessMemoryInfo` in kernel32.
This commit is contained in:
parent
84b89d7cfe
commit
cc44183787
@ -99,12 +99,20 @@ pub const ChildProcess = struct {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
.windows => {
|
||||
if (rus.rusage) |ru| {
|
||||
return ru.PeakWorkingSetSize;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
else => return null,
|
||||
}
|
||||
}
|
||||
|
||||
const rusage_init = switch (builtin.os.tag) {
|
||||
.linux => @as(?std.os.rusage, null),
|
||||
.windows => @as(?windows.PROCESS_MEMORY_COUNTERS, null),
|
||||
else => {},
|
||||
};
|
||||
};
|
||||
@ -364,6 +372,13 @@ pub const ChildProcess = struct {
|
||||
}
|
||||
});
|
||||
|
||||
if (self.request_resource_usage_statistics) {
|
||||
var pmc: windows.PROCESS_MEMORY_COUNTERS = undefined;
|
||||
if (windows.kernel32.K32GetProcessMemoryInfo(self.id, &pmc, @sizeOf(windows.PROCESS_MEMORY_COUNTERS)) != 0) {
|
||||
self.resource_usage_statistics.rusage = pmc;
|
||||
}
|
||||
}
|
||||
|
||||
os.close(self.id);
|
||||
os.close(self.thread_handle);
|
||||
self.cleanupStreams();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user