forked from adaloveless/commonx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBrainScanWindowsGUI.pas
More file actions
77 lines (56 loc) · 1.73 KB
/
BrainScanWindowsGUI.pas
File metadata and controls
77 lines (56 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
unit BrainScanWindowsGUI;
interface
uses GUIHelpers, windows, controls, comctrls, bigbrainultra, sysutils;
procedure MemList(lv: TListView; lvRef: TListView);
implementation
procedure MemList(lv: TListView; lvRef: TListView);
var
t: integer;
bm: TBlockManager;
li: TlistItem;
id: cardinal;
u: nativeint;
begin
SyncListView(lv, ManMan.ManagerCount,8);//sync once to get in the ballpark
manman.Lock;
try
SyncListView(lv, ManMan.ManagerCount, 8);//sync again under lock. should be already in the ballpark
for t:= 0 to ManMan.managercount-1 do begin
bm := manman.Managers[t];
if bm is TThreadBlockManager then
id := TThreadBlockManager(bm).LastOwnedThreadID
else
id := 0;
li := lv.items[t];
if bm.TryLock then
try
li.caption := inttostr(id);
li.subitems[0] := inttostr(bm.USedBytes);
li.subitems[1] := inttostr(bm.FreeBytes);
li.subitems[2] := inttostr(bm.AllocBytes);
li.subitems[3] := inttostr(bm.WasteBytes);
li.subitems[4] := inttostr(bm.BlockCount);
if bm.BlockCount> 0 then begin
li.subitems[5] := inttostr(bm.AllocBytes div bm.BlockCount);
end else begin
li.subitems[5] := '0';
end;
li.SubItems[6] := '';
li.SubItems[7] := '';
if lvRef <> nil then
for u := 0 to lvRef.items.count- 1do begin
if lvRef.items[u].caption = li.caption then begin
li.SubItems[6] := lvRef.items[u].subitems[0];
li.SubItems[7] := lvRef.items[u].subitems[1];
li.ImageIndex := lvRef.items[u].ImageIndex;
end;
end;
finally
bm.Unlock;
end;
end;
finally
manman.Unlock;
end;
end;
end.