Overview
Features
Download
Documentation
Community
Add-Ons & Services

How to free memory after Poco::XML::DOMParser::parse()?

Please post support and help requests here.

How to free memory after Poco::XML::DOMParser::parse()?

Postby AlexeyM » 01 Jul 2009, 21:55

Code: Select all
void testXMLMemoryLeak()
{
        std::ifstream istr("test.xml");
        std::stringstream buf;
        buf << istr.rdbuf();
        std::string s = buf.str();

        for (int i = 0; i < 100000; ++i)
        {
                Poco::XML::DOMParser parser;
                Poco::XML::Document * document = parser.parseString(s);

                // how to release document?
        }
}
AlexeyM
 
Posts: 2
Joined: 01 Jul 2009, 21:50

Re: How to free memory after Poco::XML::DOMParser::parse()?

Postby guenter » 02 Jul 2009, 08:52

Code: Select all
document->release();


or even better - have it released automatically:

Code: Select all
Poco::AutoPtr<POCO::XML::Document> pDocument = parser.parseString(s);
guenter
 
Posts: 1134
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: How to free memory after Poco::XML::DOMParser::parse()?

Postby AlexeyM » 02 Jul 2009, 14:47

Thanks!
I think, this need to be represented in documentation: http://pocoproject.org/poco/docs/Poco.X ... arser.html
(for example, there is note for methods returning NodeList*: "The returned NodeList must be released with a call to release() when no longer needed.")
AlexeyM
 
Posts: 2
Joined: 01 Jul 2009, 21:50


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest