I was trying to run an example of wasteful, inefficient string manipulation to see what happens to memory consumption, without Fastmm.
I expected the end result to be high memory consumption, de-fragmented, not leaving much free memory for project to use.
But at the end of parsing the project uses almost the same system memory:
Start:
End:
During the parsing the memory consumption is all over, the highest over 1GB:
Here is example of string manipulation:
uses StrUtils;
const cLoop = 100;
cMultiplyString = 100000;
function MultiplyStr(aStr: string; aMultiplier: integer): string;
var i: Integer;
begin
for i := 1 to aMultiplier do
Result := Result + aStr;
end;
function Parse(aString: string): string;
var s1, s2: string;
i: Integer;
begin
s1 := MidStr(Copy(MidStr(aString, 1, Length(aString) - 2), 1, Length(aString) - 2), 10, Length(aString) div 2);
for i := 1 to 100 do
Delete(s1, 1, 1);
s2 := s1 + s1;
end;
procedure TForm2.Button1Click(Sender: TObject);
var s: string;
i: integer;
begin
for i := 1 to cLoop do
begin
s := '';
s := Parse(MultiplyStr('STRING_TO_PARSE' + i.ToString, cMultiplyString));
end;
end;
Is Delphi's memory manager so good that even if the work is wasteful, inefficient string manipulation, when it ends it cleans up memory very well?