2006/6/8, Marc Weustink <[EMAIL PROTECTED]>:
I think, this is not really a memory leak, but more likely memory
fragmentation, since you are allocating random lengths. However I don't
know if SetLength reduces the mem when the length of an array is
shortened. It might be that you are working with just one array of
length 1023
You are right; I removed the randomizer part and the memory size is
not increasing. So this was probably because all the 1024 lines where
not all used.
But what I do not understand is that the memory goes up (~1K) and is
never released (mem usage of the application while it run).
Here is the new version: the goal is to stabilize the final result...
to make sure the 1024 is used. The mem increases for a while and
*seams* to stabilize at some point.
procedure TMainForm.Button1Click(Sender: TObject);
var
a: array of PChar;
i: Integer;
j: Integer;
begin
Randomize;
for i := 0 to 10000 do
begin
if i = 10000 then
SetLength(a, 1024)
else
SetLength(a, Random(1024));
for j := 0 to High(a) do
a[j] := 'this is a nice phrase to test teh pchar stuff, yeah,
the phrase is of fixed length, but I''ve no time to waste on this.';
end;
end;
--
Alexandre Leclerc
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives