calendar demo (googleapi, googleclient) memory lack
Original Reporter info from Mantis: nomorelogic
-
Reporter name:
Original Reporter info from Mantis: nomorelogic
- Reporter name:
Description:
Found lack of memory in TBaseObject.ClearChildren
Steps to reproduce:
To reproduce:
- build calendar demo with heaptrace and run from shell
- click button [Fetch calendars]
- close the application
heaptrace will show not freed mem blocks:
- 1 for TCalendarList.items dynamic array
- 1 for each reminder list set in each calender
Additional information:
I fixed this bug with a SetLength statement : search following code in method
// nomorelogic patch.begin
SetLength(TObjectArr(A), 0);
// nomorelogic patch.end
unit restbase
...
procedure TBaseObject.ClearChildren(ChildTypes: TChildTypes);
Type
TObjectArr = Array of TObject;
var
PL: PPropList;
P : PPropInfo;
i,j,count,len:integer;
A : pointer;
PA : ^pdynarraytypeinfo;
O : TObject;
begin
Count:=GetPropList(Self,PL);
try
for i:=0 to Count-1 do
begin
P:=PL^[I];
case P^.PropType^.Kind of
tkClass:
if (ctObject in ChildTypes) then
begin
// Writeln(ClassName,' Examining object: ',P^.Name);
O:=GetObjectProp(Self,P);
O.Free;
SetObjectProp(Self,P,Nil);
end;
tkDynArray:
if (ctArray in ChildTypes) then
begin
len:=Length(P^.PropType^.Name);
PA:=@(pdynarraytypeinfo(P^.PropType)^.eletype)+len;
if PTYpeInfo(PA^)^.Kind=tkClass then
begin
A:=GetDynArrayProp(P);
// Writeln(ClassName,' Examining array: ',P^.Name,'Count:',Length(TObjectArr(A)));
For J:=0 to Length(TObjectArr(A))-1 do
begin
FreeAndNil(TObjectArr(A)[J]);
end;
end;
// Length is set to nil by destructor
// nomorelogic patch.begin
SetLength(TObjectArr(A), 0);
// nomorelogic patch.end
end;
end;
end;
finally
FreeMem(PL);
end;
end;
Mantis conversion info:
- Mantis ID: 29487
- Version: 3.0.1
- Fixed in version: 3.1.1
- Fixed in revision: 33293 (#998b6665)
- Monitored by: » nomorelogic (nomorelogic)
- Target version: 3.0.2