You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by "energumen@buaa.edu.cn" <en...@buaa.edu.cn> on 2005/10/21 11:54:21 UTC

memory leak problem

hello,everybody:
   there is about 8K memory leak in my code below:


			try
			{
				XMLPlatformUtils::Initialize();
			}
			catch (const XMLException& toCatch)
			{
				LOG4CXX_ERROR(m_logger, "Error during initializing XML parser!(" << X(toCatch.getMessage()) << ")" );
				return;
			}
			SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
			parser->setContentHandler(this);
			parser->parse(filename);
			delete(parser);
			try
			{
				XMLPlatformUtils::Terminate();
			}
			catch (const XMLException& toCatch)
			{
				LOG4CXX_ERROR( m_logger, "Error during terminate XML parser!(" << X(toCatch.getMessage()) << ")" );
				return ;
			}

 my parser  just do nothing here, but there is about 8K memory leak.
 so i wonder whether i forget to delete something here ?


Re: memory leak problem

Posted by Alberto Massari <am...@datadirect.com>.
Hi,
do you still see the leak if you remove the line 
parser->setContentHandler(this)? If it disappears, you are probably 
allocating some data inside the ContentHandler callbacks.

Alberto

At 17.54 21/10/2005 +0800, energumen@buaa.edu.cn wrote:
>hello,everybody:
>    there is about 8K memory leak in my code below:
>
>
>                         try
>                         {
>                                 XMLPlatformUtils::Initialize();
>                         }
>                         catch (const XMLException& toCatch)
>                         {
>                                 LOG4CXX_ERROR(m_logger, "Error 
> during initializing XML parser!(" << X(toCatch.getMessage()) << ")" );
>                                 return;
>                         }
>                         SAX2XMLReader* parser = 
> XMLReaderFactory::createXMLReader();
>                         parser->setContentHandler(this);
>                         parser->parse(filename);
>                         delete(parser);
>                         try
>                         {
>                                 XMLPlatformUtils::Terminate();
>                         }
>                         catch (const XMLException& toCatch)
>                         {
>                                 LOG4CXX_ERROR( m_logger, "Error 
> during terminate XML parser!(" << X(toCatch.getMessage()) << ")" );
>                                 return ;
>                         }
>
>  my parser  just do nothing here, but there is about 8K memory leak.
>  so i wonder whether i forget to delete something here ?