Hi,
Xerces Version Used : 2.5.0
OS : RH 9.0
GCC Version : 3.3.3 20040412
We are observing memory leak/usage ( using:top/ps
commands) with getElementsByTagName(). Attached find a
sample app which helps reproduce this issue.
Input file contais sample entries. App. tries to
search for non-existent entries in this XML file.
Please let me know if its an issue already known with
2.5.0 version.
-> Ram
__________________________________
Yahoo! Mail for Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.
http://mobile.yahoo.com/learn/mail #include <iostream>
#include <string>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/dom/DOMWriterFilter.hpp>
#include <xercesc/framework/LocalFileFormatTarget.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
XERCES_CPP_NAMESPACE_USE
int main(int argc, char * argv[])
{
XercesDOMParser *m_parser ;
DOMDocument* m_doc ;
DOMWriter *m_Serializer;
bool doNamespaces = false;
bool doSchema = false;
bool schemaFullChecking = false;
XMLCh* gOutputEncoding = 0;
bool gSplitCdataSections = true;
bool gDiscardDefaultContent = true;
bool gUseFilter = false;
bool gFormatPrettyPrint = true;
bool gWriteBOM = false;
bool gDoNamespaces = false;
bool gDoSchema = false;
bool gSchemaFullChecking = false;
bool gDoCreate = false;
XercesDOMParser::ValSchemes gValScheme =
XercesDOMParser::Val_Auto;
XMLPlatformUtils::Initialize();
XMLCh* lsString = XMLString::transcode("LS");
DOMImplementationLS *impl =
DOMImplementationRegistry::getDOMImplementation(lsString);
XMLString::release(&lsString);
m_parser = new XercesDOMParser() ;
if(m_parser == NULL){
std::cout<<"Null Parser Object";
exit(1);
}
std::cout<<"Parser created";
m_parser->setValidationScheme(gValScheme);
m_parser->setDoNamespaces(gDoNamespaces);
m_parser->setDoSchema(gDoSchema);
m_parser->setValidationSchemaFullChecking(gSchemaFullChecking);
m_parser->setCreateEntityReferenceNodes(gDoCreate);
m_Serializer = ((DOMImplementationLS*)impl)->createDOMWriter();
// set user specified output encoding
m_Serializer->setEncoding(gOutputEncoding);
// set feature if the serializer supports the feature/mode
if (m_Serializer->canSetFeature(XMLUni::fgDOMWRTSplitCdataSections,
gSplitCdataSections))
m_Serializer->setFeature(XMLUni::fgDOMWRTSplitCdataSections,
gSplitCdataSections);
if (m_Serializer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent,
gDiscardDefaultContent))
m_Serializer->setFeature(XMLUni::fgDOMWRTDiscardDefaultContent,
gDiscardDefaultContent);
if (m_Serializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
gFormatPrettyPrint))
m_Serializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
gFormatPrettyPrint);
if (m_Serializer->canSetFeature(XMLUni::fgDOMWRTBOM, gWriteBOM))
m_Serializer->setFeature(XMLUni::fgDOMWRTBOM, gWriteBOM);
m_parser->parse(argv[1]);
m_doc = m_parser->getDocument() ;
char * usnLookUpValue = new char[10];
char dest[10] = {0};
int j=0;
while(1){
memcpy(usnLookUpValue,dest,10);
sprintf(usnLookUpValue,"%d",j++);
XMLCh* fUnicodeForm = XMLString::transcode(usnLookUpValue);
DOMNodeList* resultNodes =
m_doc->getElementsByTagName(fUnicodeForm) ;
XMLString::release(&fUnicodeForm);
if(j > 1000000)
j=0;
}
delete usnLookUpValue;
m_Serializer->release();
delete m_Serializer ;
delete m_parser;
XMLPlatformUtils::Terminate();
}
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<catalog>
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
</catalog>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]