Skip to content

Instantly share code, notes, and snippets.

@bero
Created November 13, 2021 15:07
Show Gist options
  • Save bero/6cf25295d7bf35b50a9a88cc6b632843 to your computer and use it in GitHub Desktop.
Save bero/6cf25295d7bf35b50a9a88cc6b632843 to your computer and use it in GitHub Desktop.
Example of how to handle memory in a list
unit Unit3;
interface
procedure TestMemory;
implementation
uses
Classes,
Contnrs,
SysUtils;
procedure TestMemory;
var
i, t, Size, NTests: Integer;
list: TObjectList;
begin
NTests := 5;
for t := 0 to NTests do
begin
Size := 50000;
list := TObjectList.Create;
try
for i := 0 to Size do
list.Add(TList.Create); // might be any class instantiation
finally
list.Free;
end;
end;
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment