You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by "Solinski, Mark" <ma...@sap.com> on 2000/02/22 22:23:20 UTC

XML4C++ 1.1.0 memory leaks

I have found a few memory leaks in the XML4C++ 1.1.0 DLL.  We are building
COM components under
Win32 which parse XML files.  Since these COM components are loaded and
unloaded multiple times in the same process address space, minor memory
leaks tend to accumulate.  To find these, I built a DLL with one exported
function, void fnTestXML().  I then created a test harness executable which
dynamically loads the DLL, with LoadLibrary, calls fnTextXML (loaded address
retrieved from GetProcAddress), and then unloads the DLL.  I've written
fnTestXML to have the code body of the various sample applications -
DOMPrint, SAXPrint, CreateDOMDocument and Pparse and used CompuWare's
BoundsChecker to test for memory leaks.  This is what I found:

DStringPool.cpp:  DStringPool::getStaticString does a "new DOMString(in)"
which is called from many locations but the string is never deleted.

DOMString.cpp: DOMString::getMutex does a "new XMLMutex" which is never
deleted.

DOMString.cpp: DOMStringHandle::operator new does a "new
DOMStringHandle[allocGroupSize]" which is never deleted AND if it is called
more than allocGroupSize times (creating more than allocGroupSize
DOMStrings), the first "new" is dereferenced as a "new
DOMStringHandle[allocGroupSize]" is called.

XMLScanner.cpp:  gScannerMutex() does a "new XMLMutex" that is never
deleted.

Mutexes.cpp:  The destructor ~XMLMutex after calling closeMutex should
delete fHandle.

PlatformUtils.cpp:  XMLPlatformUtils::fgNetAccessor and
XMLPlatformUtils::fgTransService are never deleted.

PlatformUtils.cpp:  XMLPlatformUtils::Initialize does a "new XMLMutex" that
is never deleted.

XMLException.cpp:  gMsgMutex() does a "new XMLMutex" that is never deleted.

TransService.cpp:  XMLTransService::initTransService() does a "new
RefHashTableOf<ENameMap>(103)" that is never deleted.  This can be fixed
easily by replacing...

gMappings = new RefHashTableOf<ENameMap>(103);

...with...

static RefHashTableOf<ENameMap> mappings(103);
gMappings = &mappings;

Win32PlatformUtils.cpp:  XMLPlatformUtils::loadMsgSet returns "new
Win32MsgLoader(msgDomain)" that is never deleted.

I hope this helps.  If you need further information send me a note.

Mark Solinski
SAP Campbell