You need to make certain that you code is using the same runtime library as Xerces.
In Visual C++ 6.0, Xerces uses msvcrt.dll and msvcrtd.dll - production and debug versions. In VC++, your project may be linked to any one or more of a few different runtime libraries. (You only want to be linked to one runtime library in any given application.) Different versions of the runtime libraries use different heaps. If your code is a different version of the runtime library, trying to delete the buffer allocated by transcode will result in an exception due to the fact that the buffer was actually allocated on a DIFFERENT heap... I know this, because it took me a little while to figure it out... I don't know how many people have ran into this - I was able to simply change the runtime library that I was using - but, there might be those that cannot do this. A simple and portable solution to this problem would be to create a global delete function in Xerces: // file: XercesAlloc.hpp void XercesDelete(void *pVoid) { delete pVoid; } void XercesDeleteArray(void *pVoid) { delete [] pVoid; } Then, instead of calling 'delete[] pChar' you could call 'XercesDeleteArray(pChar)'. Thanks, -----Original Message----- From: MATTHEWS,HEATHER (HP-Vancouver,ex1) [mailto:[EMAIL PROTECTED] Sent: Monday, March 27, 2000 12:34 PM To: '[EMAIL PROTECTED]' Subject: RE: memory management and leaks using C++ I've been following the discussion centered around memory leaks and I myself have found the same problem. I know that it occurs because I don't correctly clean things up after I call transcode() but when I call delete [] using the pointer that is returned from a transcode() call I get an exception. How exactly do you delete the DOMString.transcode() memory allocation? -----Original Message----- From: James Pearson [mailto:[EMAIL PROTECTED] Sent: Saturday, March 04, 2000 9:50 AM To: [EMAIL PROTECTED] Subject: RE: The DOM parser and memory management? (NEWBIE) As it turns out, I found that I wasn't calling delete after I used DOMString.transcode() - which I was calling all over the place. A good lesson. Jim Pearson -----Original Message----- From: Andy Clark [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 01, 2000 9:18 PM To: [EMAIL PROTECTED] Subject: Re: The DOM parser and memory management? (NEWBIE) James Pearson wrote: > I've noticed that memory usage climbs as I keep parsing new input files. I > had assumed that > Xerces would auto-magically handle the memory behind the scenes, but now I > wonder if I > have to "delete" the DOM_Document after I'm finished with it and before I > parse a new file. > (Of course my memory leaks could just be my lousy coding... nah.) Please pardon a Java guy for butting in here... I remember Andy Heninger doing a lot of work on the DOM implementation to make sure that it didn't leak memory. But... if you're not deleting the DOM_Document object then you *will* definitely leak. -- Andy Clark * IBM, JTC - Silicon Valley * [EMAIL PROTECTED]