DefineProperties together with XMLConf causes memory leak
Original Reporter info from Mantis: 007
-
Reporter name: lainz
Original Reporter info from Mantis: 007
- Reporter name: lainz
Description:
Defining a binary property in a custom component, reading that binary stream with XMLConfig causes a memory leak.
I'm not sure where is the error, if in the DefineProperties or in the XMLConfig.
Heaptrc:
PROCESSRESOURCE, line 2080 of include/customform.inc
INITCOMPONENT, line 3153 or lresources.pp
INITLAZRESOURCECOMPONENT, line 3180 or lresources.pp
INITRESOURCECOMPONENT, line 798 or lresources.pp
PROCESSRESOURCE, line 2080 of include/customform.inc
Parts of the source:
procedure TBGRASVGImageList.DefineProperties(Filer: TFiler);
begin
inherited DefineProperties(Filer);
Filer.DefineBinaryProperty('Items', ReadData, WriteData, True);
end;
procedure TBGRASVGImageList.ReadData(Stream: TStream);
var
FXMLConf: TXMLConfig;
begin
FXMLConf := TXMLConfig.Create(Self);
try
Stream.Position := 0;
FXMLConf.LoadFromStream(Stream); <---- ERROR
Load(FXMLConf);
finally
FXMLConf.Free;
end;
end;
Full source:
https://forum.lazarus.freepascal.org/index.php?topic=54216.msg402603;topicseen#new
Steps to reproduce:
Install bgrabitmap and bgracontrols, drop a TBGRASVGImageList, add an SVG image. Run the program, close the program. It crashes with Heaptrc information available.
Mantis conversion info:
- Mantis ID: 38774
- OS: Windows
- OS Build: 10
- Build: 64771
- Platform: x86
- Version: 2.1 (SVN)