<pre>
<code><font size=2 face="Courier New"><b>type
</b>PPtr = ^TPtr;
TPtr = <b>packed record
</b>Next: PPtr;
<b>end</b>;
<br>
<b>procedure </b>CleanMemory;
<br>
<b>procedure </b>Release(P: PPtr);
<b>begin
if </b>P <> <b>nil then
begin
</b>Release(P.Next);
VirtualFree(P, <font color="#0000FF">0</font>, MEM_RELEASE);
<b>end</b>;
<b>end</b>;
<br>
<b>var
</b>R,P: PPtr;
S: Cardinal;
L: Integer;
K: PChar;
M: TMemoryStatus;
<b>begin
</b>R := <b>nil</b>;
S := <font color="#0000FF">1024 </font>* <font color="#0000FF">64</font>;
<b>try
repeat
</b>P := VirtualAlloc(<b>nil</b>, S, MEM_COMMIT, PAGE_READWRITE <b>or </b>PAGE_NOCACHE);
<b>if </b>P <> <b>nil then
begin
</b>K := PChar(P);
L := <font color="#0000FF">0</font>;
<b>while </b>L < S <b>do
begin
</b>K^ := <font color="#0000FF">#55</font>;
Inc(K, <font color="#0000FF">1024</font>);
Inc(L, <font color="#0000FF">1024</font>);
<b>end</b>;
P.Next := R;
R := P;
<b>end else </b>S := S <b>shr </b><font color="#0000FF">1</font>;
M.dwLength := SizeOf(M);
GlobalMemoryStatus(M);
<b>until </b>(S = <font color="#0000FF">0</font>) <b>or </b>(M.dwMemoryLoad >= <font color="#0000FF">99</font>);
<b>finally
</b>Release(R);
<b>end</b>;
<b>end</b>;
</font>
</code></pre>


<code><font size=2 face="Courier New"><b>type
</b>PPtr = ^TPtr;
TPtr = <b>packed record
</b>Next: PPtr;
<b>end</b>;
<br>
<b>procedure </b>CleanMemory;
<br>
<b>procedure </b>Release(P: PPtr);
<b>begin
if </b>P <> <b>nil then
begin
</b>Release(P.Next);
VirtualFree(P, <font color="#0000FF">0</font>, MEM_RELEASE);
<b>end</b>;
<b>end</b>;
<br>
<b>var
</b>R,P: PPtr;
S: Cardinal;
L: Integer;
K: PChar;
M: TMemoryStatus;
<b>begin
</b>R := <b>nil</b>;
S := <font color="#0000FF">1024 </font>* <font color="#0000FF">64</font>;
<b>try
repeat
</b>P := VirtualAlloc(<b>nil</b>, S, MEM_COMMIT, PAGE_READWRITE <b>or </b>PAGE_NOCACHE);
<b>if </b>P <> <b>nil then
begin
</b>K := PChar(P);
L := <font color="#0000FF">0</font>;
<b>while </b>L < S <b>do
begin
</b>K^ := <font color="#0000FF">#55</font>;
Inc(K, <font color="#0000FF">1024</font>);
Inc(L, <font color="#0000FF">1024</font>);
<b>end</b>;
P.Next := R;
R := P;
<b>end else </b>S := S <b>shr </b><font color="#0000FF">1</font>;
M.dwLength := SizeOf(M);
GlobalMemoryStatus(M);
<b>until </b>(S = <font color="#0000FF">0</font>) <b>or </b>(M.dwMemoryLoad >= <font color="#0000FF">99</font>);
<b>finally
</b>Release(R);
<b>end</b>;
<b>end</b>;
</font>
</code></pre>


Comment