xerces and memory usage

i am using xerces 2.8.0 in linux platform.For each xml file(very huge file) parsing i can see huge memory increase.

Below is the sample code

#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>

using namespace xercesc;

class ParseWrite
{
XercesDOMParser* parser;
DOMDocument * pDoc;

public:
ParseWrite()
{
try
{
XMLPlatformUtils::Initialize();
} catch(...)
{
}

parser = new XercesDOMParser();
parser->setValidationScheme(XercesDOMParser::Val_Never);
parser->setDoNamespaces(false);
parser->setDoSchema(false);
parser->setValidationSchemaFullChecking(false);
parser->setLoadExternalDTD(false);
pDoc = 0;
}

~ParseWrite()
{
delete parser;
XMLPlatformUtils::Terminate();
}

int Parse(const char * infile)
{
parser->parse(infile);
pDoc = parser->getDocument();

//Traversing code here

parser->resetDocumentPool();
return 0;
}
};

ParseWrite Parser;

int main(int argc,char** argv)
{
if(argc < 2)//check atleast 1 file is passed
return 0;

for(int i = 1; i < argc; i++)
{
Parser.Parse(argv[i]);
sleep(10);
somefun();
someotherfun();
}

//some other code blocks

return 0;
}

Note: Invoked sleep() after each file parse to check whether the memory is released,its not.any way to release the memory before the next parse starts?
Last edited on
Topic archived. No new replies allowed.