Catalog · How the catalog works
Auto-Free-Object-Memory
Automatic local free object/memory without memory consumption penalty
- ★ 3 on GitHub
Anyone may press Interesting, signed in or not. It helps others find this project.
README
Auto Free Object/Memory
Automatic local free object/memory without memory consumption penalty. Free Object/Memory at the exit of the function/procedure.
Simple example :
var
SList1,SList2,SList3:TStringList;
begin
SList1 := nil;
SList2 := nil;
SList3 := nil;
try
SList1 := TStringList.Create;
SList2 := TStringList.Create;
SList3 := TStringList.Create;
//use it!
//...
finally
SList1.Free;
SList2.Free;
SList3.Free;
end;
end;Replaced by :
var
SList1,SList2,SList3:TStringList;
begin
AutoFree(SList1, TStringList.Create);
AutoFree(SList2, TStringList.Create);
AutoFree(SList3, TStringList.Create);
//use it!
//...
end;You can write this too :
var
List:TList;
Bytes:PByte;
begin
List := TList.Create;
AutoFree(List);
//use it!
GetMem(Bytes, 1024*Sizeof(Byte));
AutoFreeMem(Bytes);
//use it!
end;
