RB14.03. Memory leak in TppViewer.DoOnPageChange;
Hello everybody.
I think that I (actually it was FastMM) has just found a memory leak in
TppViewer.DoOnPageChange.
procedure TppViewer.DoOnPageChange;
var
lParams: TraParamList;
liPageNo: Integer;
begin
if Assigned(FOnPageChange) then FOnPageChange(Self);
liPageNo := CurrentPage.AbsolutePageNo;
lParams := TraParamList.Create;
lParams.AddParam('PageNo', daInteger, nil, '', False, False);
lParams.CreateValuePointer(0, liPageNo);
FWalkieTalkie.SendEventNotify(FWalkieTalkie, ciViewerPageChange, lParams);
end; {procedure, DoOnPageChange}
The lParams object and everything it owns is not freed. I have modified the
code in the following way and the leak has gone.
procedure TppViewer.DoOnPageChange;
var
lParams: TraParamList;
liPageNo: Integer;
begin
if Assigned(FOnPageChange) then FOnPageChange(Self);
liPageNo := CurrentPage.AbsolutePageNo;
lParams := TraParamList.Create;
try
lParams.AddParam('PageNo', daInteger, nil, '', False, False);
lParams.CreateValuePointer(0, liPageNo);
FWalkieTalkie.SendEventNotify(FWalkieTalkie, ciViewerPageChange,
lParams);
finally
FreeAndNil(lParams);
end;
end; {procedure, DoOnPageChange}
Can you please confirm that this fix is correct and lParams shouldn't be
destroyed somewhere inside of SendEventNotify?
I think that I (actually it was FastMM) has just found a memory leak in
TppViewer.DoOnPageChange.
procedure TppViewer.DoOnPageChange;
var
lParams: TraParamList;
liPageNo: Integer;
begin
if Assigned(FOnPageChange) then FOnPageChange(Self);
liPageNo := CurrentPage.AbsolutePageNo;
lParams := TraParamList.Create;
lParams.AddParam('PageNo', daInteger, nil, '', False, False);
lParams.CreateValuePointer(0, liPageNo);
FWalkieTalkie.SendEventNotify(FWalkieTalkie, ciViewerPageChange, lParams);
end; {procedure, DoOnPageChange}
The lParams object and everything it owns is not freed. I have modified the
code in the following way and the leak has gone.
procedure TppViewer.DoOnPageChange;
var
lParams: TraParamList;
liPageNo: Integer;
begin
if Assigned(FOnPageChange) then FOnPageChange(Self);
liPageNo := CurrentPage.AbsolutePageNo;
lParams := TraParamList.Create;
try
lParams.AddParam('PageNo', daInteger, nil, '', False, False);
lParams.CreateValuePointer(0, liPageNo);
FWalkieTalkie.SendEventNotify(FWalkieTalkie, ciViewerPageChange,
lParams);
finally
FreeAndNil(lParams);
end;
end; {procedure, DoOnPageChange}
Can you please confirm that this fix is correct and lParams shouldn't be
destroyed somewhere inside of SendEventNotify?
This discussion has been closed.
Comments
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com