Leaked objects when parsing XML

Hi there,

I’m trying to implement a MusicXML parser, but I encounter an error that I’m not able to resolve…
Here is my code :

File file("C:\\my\\path\\myFile.xml");
XmlDocument document(file);

XmlElement* root = document.getDocumentElement();

The error Visual Studio is throwing is :

Nom Valeur Type
:arrow_forward: this 0x00007ff7fbecae78 {MyProject.exe!juce::LeakedObjectDetector<juce::XmlElement>::LeakCounter counter} {…} juce::LeakedObjectDetector<juce::XmlElement>::LeakCounter *

Thanks in advance for your time !


You need to delete the XmlElement you get from getDocumentElement. Or rather, use a smart pointer, for example :

std::unique_ptr<XmlElement> root{ document.getDocumentElement() };

Thanks alot !