Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4116294
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:41:24+00:00 2026-05-20T22:41:24+00:00

I have a leak in my application and I’ve come to reduce my code

  • 0

I have a leak in my application and I’ve come to reduce my code to the following and it’s leaking about 12kb per iteration. I cannot see if this is a problem with my code or a problem with the xerces library itself. But looking at the Private Bytes in Perfmon I can only see growth and no shrinkage, so it’s obviously leaking.

Can someone please advice what could be wrong with the following code that causes it to leak at such an incredible rate?:

(single threaded test app)

for (int x = 0; x < 1000000; x++){
        DataSerializer* ds = new DataSerializer();
        ds->test(request);
        ds->releasedocument();
        ds->destroy_xml_lib();
        delete ds;
    }

void DataSerializer::test(std::string& request)
{
    impl = initialize_impl();
}
DOMImplementation* DataSerializer::initialize_impl()
{
    try
    {
        boost::mutex::scoped_lock init_lock(impl_mtx);
        XMLPlatformUtils::Initialize();
        return DOMImplementationRegistry::getDOMImplementation(XConv("Core"));
    }
    catch(const XMLException& toCatch)
    {
        char *pMsg = XMLString::transcode(toCatch.getMessage());
        std::string msg(pMsg);
        XMLString::release(&pMsg);
    }

    return NULL;
}
void DataSerializer::destroy_xml_lib()
{
    boost::mutex::scoped_lock terminate_lock (impl_mtx); //is being used in MT app
    XMLPlatformUtils::Terminate(); 
}
void DataSerializer::releasedocument()
{
    if (document){
        document->release();
        document = NULL;
    }
}

I don’t understand how this could possibly leak? What have I missed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:41:25+00:00Added an answer on May 20, 2026 at 10:41 pm

    Where does impl get deleted?

    I know nothing more about the API than googling the docs, but they suggest to me that you should not be calling Terminate() – in a real program, other code elsewhere, possibly in other threads, may still be using the xerces library.

    The DOMImplementation is returned as a pointer and has a destructor – clear indications you have to manage its lifetime. It seems a really likely story that that is your memory leak.

    Furthermore, that the DOMImplementationRegistry::getDOMImplementation() can return NULL so you have to guard against that.

    If you can run this on Linux,use Valgrind (Purify is a commercial equivalent for windows)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with a memory leak in a .NET CF application. Using
Per this helpful article I have confirmed I have a connection pool leak in
I have memory leak in the web application (servlet) that I am working on.
I have a memory leak issue in my application which loads a large amount
I have to check connection leak in my application i.e. open connections which have
I have just resolved a memory leak in my application and now I want
I think I may have a memory leak in my LAMP application (memory gets
In our SL4 application built on Caliburn.Micro, we've come across a (another) memory leak.
I have an application that I suspect might be leaking a thread or its
What memory leak detectors have people had a good experience with? Here is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.