本文整理自网络,侵删。
//delphi 获得当前进程所使用的内存
uses PsAPI ...
//current memory size of the current process in bytes
function CurrentMemoryUsage: Cardinal;
var
pmc: TProcessMemoryCounters;
begin
pmc.cb := SizeOf(pmc) ;
if GetProcessMemoryInfo(GetCurrentProcess, @pmc, SizeOf(pmc)) then
Result := pmc.WorkingSetSize
else
RaiseLastOSError;
end;
To display the memory usage in KB, use:
ShowMessage(FormatFloat('Memory used: ,.# K', CurrentMemoryUsage / 1024)) ;
相关阅读 >>
Delphi使用ixmlhttprequest 简单获取网页源代码
更多相关阅读请进入《Delphi》频道 >>