diff --git a/lib/std/process.zig b/lib/std/process.zig index 305bcca24b..efe0a9b0e9 100644 --- a/lib/std/process.zig +++ b/lib/std/process.zig @@ -1753,7 +1753,8 @@ pub fn totalSystemMemory() TotalSystemMemoryError!u64 { if (std.os.linux.E.init(result) != .SUCCESS) { return error.UnknownTotalSystemMemory; } - return info.totalram * info.mem_unit; + // Promote to u64 to avoid overflow on systems where info.totalram is a 32-bit usize + return @as(u64, info.totalram) * info.mem_unit; }, .freebsd => { var physmem: c_ulong = undefined;