473,411 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

xml parsing memory leak

In the code below I am trying to read text in an xml file, this works
fine but creates a memory leak of about 400K each time. This code is
called from a loop in a windows service so I can not just terminate the
app to cleanup, any ideas how to free this memory.
////////////////////////

xercesc_2_4::XercesDOMParser* parser = new
xercesc_2_4::XercesDOMParser();
parser->setValidationScheme(xercesc_2_4::XercesDOMParser: :Val_Never);
parser->setDoNamespaces(false);

xercesc_2_4::ErrorHandler* errHandler = (xercesc_2_4::ErrorHandler*)
new xercesc_2_4::HandlerBase();

parser->setErrorHandler(errHandler);

string metaDataFile = GetMetadataFileName(submissionID);

try
{
parser->parse(metaDataFile.c_str());
}

catch (const xercesc_2_4::XMLException& toCatch)
{
char* message =
xercesc_2_4::XMLString::transcode(toCatch.getMessa ge());
std::cout << "Exception message is: \n" << message << "\n";
xercesc_2_4::XMLString::release(&message);
delete parser;
delete errHandler;
}

catch (const xercesc_2_4::DOMException& toCatch)
{
char* message = xercesc_2_4::XMLString::transcode(toCatch.msg);
std::cout << "Exception message is: \n" << message << "\n";
xercesc_2_4::XMLString::release(&message);
delete parser;
delete errHandler;
}

catch (...)
{
std::cout << "Unexpected Exception \n";
delete parser;
delete errHandler;
}

xercesc_2_4::DOMDocument* xmlDoc = parser->getDocument();

if( NULL == xmlDoc )
{
std::cout<<"xml doc is null, quit\n";
delete parser;
delete errHandler;
}
xercesc::DOMNodeList* list;
xercesc::DOMNode* node;
const XMLCh* n;
char* xmlval = "";
string szXmlVal = "";

list = xmlDoc->getElementsByTagName(
XMLString::transcode("SubmissionDate") );
node = list->item(0);
if( xercesc::DOMNode::ELEMENT_NODE == node->getNodeType() )
{
n = node->getFirstChild()->getNodeValue();
xmlval = xercesc_2_4::XMLString::transcode(n);
szXmlVal = xmlval;
xercesc_2_4::XMLString::release(&xmlval);
}
delete parser;
delete errHandler;
return szXmlVal;
/////////

Enda Mannion

Nov 23 '05 #1
0 1152

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Jeff Rodriguez | last post by:
If main is prototyped as: int main(int argc, char *argv); You will end up with a bunch of arguments in *argv, and the number in argc. Now what I want to do is emulate that same action on a...
8
by: ranjeet.gupta | last post by:
Dear All Is the Root Cause of the Memory corruption is the Memory leak, ?? suppose If in the code there is Memory leak, Do this may lead to the Memory Corruption while executing the program ? ...
17
by: José Joye | last post by:
Hi, I have implemented a Service that is responsible for getting messages from a MS MQ located on a remote machine. I'm getting memory leak from time to time (???). In some situation, it is...
4
by: Don Nell | last post by:
Hello Why is there a memory leak when this code is executed. for(;;) { ManagementScope scope = new ManagementScope(); scope.Options.Username="username"; scope.Options.Password="password";...
20
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
23
by: James | last post by:
The following code will create memory leaks!!! using System; using System.Diagnostics; using System.Data; using System.Data.SqlClient; namespace MemoryLeak
7
by: Salvador | last post by:
Hi, I am using WMI to gather information about different computers (using win2K and win 2K3), checking common classes and also WMI load balance. My application runs every 1 minute and reports...
3
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". ...
22
by: Peter | last post by:
I am using VS2008. I have a Windows Service application which creates Crystal Reports. This is a multi theaded application which can run several reports at one time. My problem - there is a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.