Do we need to clear Integer
and string
variables?
I mean after we use integer variable, we have to make it zero also string variable have to clear for better memory performance and etc? or nothing happen?
EDIT:
For example this code is running 24h/7 in a server and don't turn off or restart server and calling this procedure more than 3000 time in 5 minute.
procedure somejob;
i:integer;
Test1,Test2,Test3,Test4:string;
begin
{Some more job....}
i := {BIG INTEGER};
Test1:= {BIG STRING};
Test2:= {BIG STRING};
Test3:= {BIG STRING};
Test4:= {BIG STRING};
{some more job....}
{we have to clear these variables or not?}
i:= 0;
Test1:= '';
Test2:='';
Test3:='';
Test4:='';
end;
No, you don't have to clear any variables in that case.
Strings are reference counted in Delphi. That means that string will be freed automatically after execution of the routine.
Integer and other simple types are allocated in stack and disappear when running thread leaves the routine.