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
|
program MaxAlloc2Go;
{$R *.res}
uses
Windows,
SysUtils;
type
TByteMatrix1024By1024 = array [0..1023, 0..1023] of Byte;
TByteMatrix1024By1024Array = array[0..2047] of ^TByteMatrix1024By1024;
var
Tableau: TByteMatrix1024By1024Array;
I, K: Integer;
begin
for I := 0 to 2047 do
begin
try
Tableau[I] := Pointer(GlobalAlloc(GMEM_FIXED, 1024*1024));
if Tableau[I] = nil then
Abort;
K := I;
except
on E: Exception do
begin
OutputDebugString(PChar(Format('Last Alloc %d', [I])));
Break;
end;
end;
end;
MessageBox(0, PChar(Format('Last Alloc %d', [K])), nil, MB_OK+MB_ICONEXCLAMATION);
if K = 2047 then
OutputDebugString('Alloc 2Go');
for I := K downto 0 do
try
// FreeMem(Tableau[I]);
if GlobalFree(Cardinal(Tableau[I])) <> 0 then
Abort;
except
on E: Exception do
OutputDebugString(PChar(Format('Free %d : %s', [K, E.Message])));
end;
end. |
Partager