Hi Wentao,

At 11.36 20/07/2007 -0400, Wentao Deng wrote:
Hi,
    Look at following simple code block:
---
    XercesDOMParser *parser = 0;
    try
    {
        XMLPlatformUtils::Initialize()
        parser = new XercesDOMParser();
    }
    catch (...)
    {
        cout<< "Unknown error detected in parse()"<<endl;
    }

    delete parser;
    XMLPlatformUtils::Terminate();
--
In my simple test application's main function, this block runs well.
But when I put this block in my business application's XML parsing
function, it fails with message
"memory corrupted...". And the error occurs only when processing the
delete statement.
Though this application is multi-threaded, I think the function is
executed in a single thread. -- would it be a problem if this function
is executed in multiple theads?

Yes, it would be a big problem if this code is executed in multiple threads, as Initialize/Terminate are not multithread-safe. Move the Initialize call in your main thread, and call Terminate just before exiting.

Alberto

Without the block, the function runs well.
So, what could be the reason of the error?
I studied the default MemoryManager, and found nothing special.
I really have no idea.

Regards,
Wentao

Reply via email to