在Windows中,我可以通过调用GetProcessMemoryInfo
来获取Peak Memory的使用情况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 OS是什么?
答案 0 :(得分:8)
您可以像这样使用/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 btyes)
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