0

Apparently there is a memory leak in this code:

procedure TForm1.Button1Click(Sender: TObject);
var
  doc: IXMLDocument;
begin
  doc := TXMLDocument.Create(Nil);
  doc.Active := True;
  doc.AddChild('test');
  doc := Nil;
end; 

Clicking on the button gives me a report of a memory leak. Is this a false positive or is there a leak? IDE is Rad Studio 10.2

vincent
  • 78
  • 7
  • [This](https://stackoverflow.com/questions/51422248/txmldocument-active-false-causes-fastmm4-errormessage-fastmm-detected-that-a#comment89818234_51422248) might be another flavor of your issue, maybe? Do you get the same leak reported when you just let the `IXMLDocument` reference run out of scope instead of using `doc := nil;` to force it? – nil Jan 29 '19 at 14:14
  • Interesting link, thanks! If I omit the `doc := nil;` I still get the leak. I tried `doc := nil` when clicking an other button (suggestion from the link you gave), but still the same. I'm using EurekaLog – vincent Jan 29 '19 at 15:13
  • Is it possible that this is a false positive. Can you reproduce this without Eureka using the built in leak detection? – David Heffernan Jan 29 '19 at 15:23
  • I added `ReportMemoryLeaksOnShutdown := True;` (hope this was what you meant) in the FormCreate: it does not report a leak! – vincent Jan 29 '19 at 15:47
  • 2
    Then I think the issue is with how you are using Eureka. – David Heffernan Jan 29 '19 at 15:58
  • 1
    No mem leak in 10.3 using FastMM4 in debug mode. – Jan Doggen Jan 30 '19 at 10:31

1 Answers1

0

I contacted Eurekalog support: it was a false positive of a RESOURCE leak (not a memory leak as my title says). Eurekalog did not report a memory leak but a resource leak,sorry for the confusion and thanks for the help (especially the suggestion of a false positive).

vincent
  • 78
  • 7