[ http://issues.apache.org/jira/browse/XERCESC-1589?page=comments#action_12414059 ]
Rinil Baxi commented on XERCESC-1589: ------------------------------------- Hi, Even I have tried out the same with latest versions but not success. Rinil > XML DOM parser does not release memory on parser:release and > resetDocumentPool() > -------------------------------------------------------------------------------- > > Key: XERCESC-1589 > URL: http://issues.apache.org/jira/browse/XERCESC-1589 > Project: Xerces-C++ > Type: Bug > Components: DOM > Versions: 2.4.0 > Environment: HP-Tandem-NonStop Kernel > Reporter: Rinil Baxi > > 1) Use the following code: > /home/Rinil/Xml/dom [2441]: more mleak.cpp > #include < string.h> > #include < cextdecs.h> > #include < iostream> > #include < xercesc/util/PlatformUtils.hpp> > #include < xercesc/parsers/AbstractDOMParser.hpp> > #include < xercesc/dom/DOMImplementation.hpp> > #include < xercesc/dom/DOMImplementationLS.hpp> > #include < xercesc/dom/DOMImplementationRegistry.hpp> > #include < xercesc/dom/DOMBuilder.hpp> > #include < xercesc/dom/DOMException.hpp> > #include < xercesc/dom/DOMDocument.hpp> > #include < xercesc/dom/DOMNodeList.hpp> > #include < xercesc/dom/DOMError.hpp> > #include < xercesc/dom/DOMLocator.hpp> > #include < xercesc/dom/DOMWriter.hpp> > #include < xercesc/framework/StdOutFormatTarget.hpp> > #include < xercesc/framework/LocalFileFormatTarget.hpp> > #include < xercesc/framework/MemBufInputSource.hpp> > #include < xercesc/framework/Wrapper4InputSource.hpp> > #include < xercesc/parsers/XercesDOMParser.hpp> > #include < xercesc/util/XMLUni.hpp> > #include < xercesc/util/XMLException.hpp> > unsigned long getMemUsage () > { > short gError = 0; > short myHandle[10]; > short attrList[10]; > short valList[10]; > short valMaxLen = 10; > short valLen = 0; > short attrs = 0; > unsigned long *memUsage; > gError = PROCESSHANDLE_GETMINE_ (&myHandle[0]); > if (gError) > return 0;35%) > memset (&attrList[0], '\0', 10); > memset (&valList[0], '\0', 10); > attrList[attrs] = 111; > attrs++; > gError = PROCESS_GETINFOLIST_ > (,,,,&myHandle[0] > ,&attrList[0] > ,attrs > ,&valList[0] > ,valMaxLen > ,&valLen > ); > if (gError) > return 0; > memUsage = (unsigned long *) (&valList[0]); > return *memUsage; > } > int main() > { > DOMImplementation *impl; > DOMBuilder *parser; > DOMDocument *doc; > const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull }; > std::cout < < "\nMEMUSAGE at Start : "< < getMemUsage(); > // Initialize the XML system > try { > XMLPlatformUtils::Initialize(); > XMLPlatformUtils::recognizeNEL(false); > } > catch (const XMLException& toCatch) { > return 1; > } > impl = DOMImplementationRegistry::getDOMImplementation(gLS); > parser = > ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, > 0); > if (parser == NULL) { > //Its known that XML system must be terminated before returning > return 1; > } > parser->setFeature(XMLUni::fgDOMNamespaces,true); > parser->setFeature(XMLUni::fgXercesSchema, false); > parser->setFeature(XMLUni::fgXercesSchemaFullChecking, false); > parser->setFeature(XMLUni::fgDOMValidateIfSchema, false); > parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true); > //Reset Document Pool > parser->resetDocumentPool(); > std::cout< < "\nMEMUSAGE before parsing: "< < getMemUsage(); > //Parse XML and get document > try{ > doc = parser->parseURI("personal.xml"); > } > catch(DOMException dome){ > //Its known that XML system must be terminated before returning > return 1; > } > std::cout< < "\nMEMUSAGE after parsing: "< < getMemUsage(); > //Reset Document Pool > parser->resetDocumentPool(); > std::cout< < "\nMEMUSAGE after resetDocumentpool(): "< < getMemUsage(); > //Release Parser > //This should also release DOMDOcument associated i.e. doc > parser->release(); > std::cout< < "\nMEMUSAGE after parser release(): "< < getMemUsage(); > XMLPlatformUtils::Terminate(); > std::cout< < "\nMEMUSAGE after Terminate(): "< < getMemUsage()< < std::endl; > return 0; > } > /home/Rinil/xml/dom [2442]: > 2) Compile using Makefiles provided with XML samples. > 3) Place a xml file to be parsed in the CWD. ie personal.xml which comes with > the samples. > 4) run mleak: > /home/RinilXml/dom [2452]: ./mleak > MEMUSAGE at Start : 16384 > MEMUSAGE before parsing: 57344 > MEMUSAGE after parsing: 245888 > MEMUSAGE after resetDocumentpool(): 245888 > MEMUSAGE after parser release(): 245888 > MEMUSAGE after Terminate(): 245888 -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
