gpt4 book ai didi

macos - 如何获得 Mac 操作系统上的峰值内存?

转载 作者:行者123 更新时间:2023-12-03 14:51:06 35 4
gpt4 key购买 nike

在 Windows 中,我可以通过调用 GetProcessMemoryInfo 获取峰值内存使用情况

function TProcess.Peek: Cardinal;
var
PMC: PPROCESS_MEMORY_COUNTERS;
PMCSize: Cardinal;
begin
PMCSize := SizeOf(PROCESS_MEMORY_COUNTERS);
GetMem(PMC, PMCSize);
try
PMC^.cb := PMCSize;
if GetProcessMemoryInfo(FHandle, PMC, PMCSize) then
Exit(PMC^.PeakWorkingSetSize)
else
Exit(0);
finally
FreeMem(PMC);
end;
end;

Mac 操作系统相当于执行此操作的是什么?

最佳答案

您可以使用/usr/bin/time -l <cmd>像这样:

/usr/bin/time -l sleep 3
3.00 real 0.00 user 0.00 sys
552960 maximum resident set size <--- this one (in bytes)
0 average shared memory size
0 average unshared data size
0 average unshared stack size
144 page reclaims
0 page faults
0 swaps
0 block input operations
0 block output operations
0 messages sent
0 messages received
0 signals received
0 voluntary context switches
2 involuntary context switches

关于macos - 如何获得 Mac 操作系统上的峰值内存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12476804/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com