0

How i can get memory ram and cpu usage used of my process? not from entire CPU.

all codes who i search on internet always retrieve from entire CPU, but i need retrieve these informations from my own process.

i'm using delphi 10.1

these code above who i did with others examples show very near the real memory usage:

var ProcHand : THandle; i : integer; WorkingSet : array[0..$3FFF - 1] of DWORD; Shared, Privates, total : Integer; begin ProcHand := OpenProcess(PROCESS_ALL_ACCESS, False, GetCurrentProcessId); Shared := 0; Privates := 0; total := 0; if QueryWorkingSet(ProcHand, @WorkingSet, SizeOf(WorkingSet)) then begin for I := 1 to WorkingSet[0] do begin if ((WorkingSet[I] and $00000FFF) and $100 <> 0) then Inc(Shared) else Inc(Privates); Application.ProcessMessages; end; end; total := WorkingSet[0] * 4; Shared := Shared * 4; Result := Format('%.2f e %f > Memory %.2f', [total / 1024, shared / 1024, ((total / 1024) - (shared / 1024))]); CloseHandle(ProcHand); 

the code are based on https://www.codeproject.com/Articles/87529/Calculate-Memory-Working-Set-Private-Programmatica

5

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.