Return-Path: Delivered-To: apmail-xerces-c-users-archive@www.apache.org Received: (qmail 7077 invoked from network); 8 Jul 2009 09:41:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Jul 2009 09:41:12 -0000 Received: (qmail 78660 invoked by uid 500); 8 Jul 2009 09:41:22 -0000 Delivered-To: apmail-xerces-c-users-archive@xerces.apache.org Received: (qmail 78524 invoked by uid 500); 8 Jul 2009 09:41:21 -0000 Mailing-List: contact c-users-help@xerces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: c-users@xerces.apache.org Delivered-To: mailing list c-users@xerces.apache.org Received: (qmail 78514 invoked by uid 99); 8 Jul 2009 09:41:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jul 2009 09:41:21 +0000 X-ASF-Spam-Status: No, hits=-1.8 required=10.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [217.194.35.70] (HELO alea.erlm.siemens.de) (217.194.35.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jul 2009 09:41:10 +0000 Received: from alea.erlm.siemens.de (localhost.localdomain [127.0.0.1]) by alea.erlm.siemens.de (Postfix) with ESMTP id 9806F8E0072 for ; Wed, 8 Jul 2009 11:40:48 +0200 (CEST) Received: from alea (localhost.localdomain [127.0.0.1]) by alea.erlm.siemens.de (Postfix) with ESMTP id 8BDDB8E0059 for ; Wed, 8 Jul 2009 11:40:48 +0200 (CEST) Received: from medeon.erlm.siemens.de (medeon.erlm.siemens.de [146.254.164.9]) by alea.erlm.siemens.de (Postfix) with ESMTP for ; Wed, 8 Jul 2009 11:40:48 +0200 (CEST) Received: from WW001E1ERLM002.ww001.siemens.net (unknown [146.254.214.66]) by medeon.erlm.siemens.de (Postfix) with ESMTP id 72FD174805A for ; Wed, 8 Jul 2009 11:40:48 +0200 (CEST) Received: from WW001E1ERLMM01.ww001.siemens.net ([146.254.214.72]) by WW001E1ERLM002.ww001.siemens.net ([146.254.214.66]) with mapi; Wed, 8 Jul 2009 11:40:46 +0200 From: "Freimann, Mario" To: "c-users@xerces.apache.org" Date: Wed, 8 Jul 2009 11:40:46 +0200 Subject: Memory Leak at XercesDOMParser parse function? Thread-Topic: Memory Leak at XercesDOMParser parse function? Thread-Index: Acn/sCs01Jmg6dTgTa2fD7F/03SaOw== Message-ID: <9B5859DE1377F64794DCB6C5483C058E0731E66970@WW001E1ERLMM01.ww001.siemens.net> Accept-Language: de-DE Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: de-DE Content-Type: multipart/alternative; boundary="_000_9B5859DE1377F64794DCB6C5483C058E0731E66970WW001E1ERLMM0_" MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org --_000_9B5859DE1377F64794DCB6C5483C058E0731E66970WW001E1ERLMM0_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable - Xerces-C++ version number: 2.8 - Platform: Windows 32Bit - Operating system and version number: Windows Server 2003 SP 2 - Compiler and version number: MSVC 6 SP6 - Built Xerces by myself I'm parsing a xml document. Therefore I have a XercesDOMParser instance. I = create this instance once and reuse it to scan one xml document cyclically.= The xml document is valid. I get some data from the document. With every p= arse Purify reports a _potential_ memory leak of 1680 Bytes. But If I start= the program without purify the memory consumption increases all the time. = So I think it is a memory leak. Is this a memory leak or do I have to add s= ome more release or cleanup calls (if so where?)? The following code extract eplains the code (error checking deleted for sim= plicity). I changed my program to do only the parse function. Creating the parser (only once): =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D DOMDocument* _xmlDoc =3D NULL; DOMNode* _actualNode =3D NULL; XercesDOMParser* _parser =3D NULL; XMLPlatformUtils::Initialize(); _parser =3D new XercesDOMParser(); _parser->setValidationScheme(XercesDOMParser::Val_Auto); _parser->setIncludeIgnorableWhitespace(false); _parser->setDoNamespaces(true); _parser->setDoSchema(false); _parser->setErrorHandler(this); Parsing the file (cyclically): =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D do { if (_xmlDoc!=3DNULL) { _xmlDoc->release(); } try { transcodexmlch =3D XMLString::transcode(filename); _parser->parse(transcodexmlch); XMLString::release(&transcodexmlch); } catch ()... _xmlDoc =3D _parser->getDocument(); _actualNode =3D _xmlDoc->getDocumentElement(); } while ( true ); Purify shows a memory leak of total 2680 Bytes. The following trace gives t= he biggest memory leak: [I] MPK: Potential memory leak of 1288 bytes from 23 blocks allocated in xe= rcesc_2_8::MemoryManagerImpl::allocate(UINT) [XERCES-C_2_8D.DLL] Offset 0x00000008 referenced by 0x024e9370, a location in a C++ new= block Offset 0x00000008 referenced by 0x024ef170, a location in a C++ new= block Distribution of potentially leaked blocks Allocation location new(UINT) [E:\DEVELOP\program\DEBUG\XERCES-C_2_8D.DLL] xercesc_2_8::MemoryManagerImpl::allocate(UINT) [E:\develop\xerc= es-c-src_2_8_0\src\xercesc\internal\MemoryManagerImpl.cpp:35] { void* memptr; try { =3D> memptr =3D ::operator new(size); } catch(...) { throw OutOfMemoryException(); xercesc_2_8::XMemory::new(UINT,MemoryManager::xercesc_2_8 *) [E= :\develop\xerces-c-src_2_8_0\src\xercesc\util\XMemory.cpp:67] size_t headerSize =3D XMLPlatformUtils::alignPointerFor= NewBlockAllocation( sizeof(MemoryManage= r*)); =3D> void* const block =3D manager->allocate(headerSize + = size); *(MemoryManager**)block =3D manager; return (char*)block + headerSize; xercesc_2_8::IGXMLScanner::scanStartTagNS(bool&) [E:\develop\xe= rces-c-src_2_8_0\src\xercesc\internal\IGXMLScanner.cpp:2393] if (fGrammarType =3D=3D Grammar::DTDGrammarType) { elemDecl =3D new (fMemoryManager) DTDElementDec= l( qnameRawBuf, uriId, DTDElementDecl::Any, fM= emoryManager =3D> ); elemDecl->setId(fDTDElemNonDeclPool->put((DTDEl= ementDecl*)elemDecl)); } else if (fGrammarType =3D=3D Grammar::SchemaGrammar= Type) { xercesc_2_8::IGXMLScanner::scanContent(void) [E:\develop\xerces= -c-src_2_8_0\src\xercesc\internal\IGXMLScanner.cpp:896] case Token_StartTag : if (fDoNamespaces) =3D> scanStartTagNS(gotData); else scanStartTag(gotData); break; xercesc_2_8::IGXMLScanner::scanDocument(InputSource::xercesc_2_= 8 const&) [E:\develop\xerces-c-src_2_8_0\src\xercesc\internal\IGXMLScanner.= cpp:214] else { // Scan content, and tell it its not an externa= l entity =3D> if (scanContent()) { // Do post-parse validation if required if (fValidate) xercesc_2_8::XMLScanner::scanDocument(WORD const* const) [E:\de= velop\xerces-c-src_2_8_0\src\xercesc\internal\XMLScanner.cpp:460] } Janitor janSrc(srcToUse); =3D> scanDocument(*srcToUse); } void XMLScanner::scanDocument( const char* const systemI= d) xercesc_2_8::AbstractDOMParser::parse(WORD const* const) [E:\de= velop\xerces-c-src_2_8_0\src\xercesc\parsers\AbstractDOMParser.cpp:538] try { fParseInProgress =3D true; =3D> fScanner->scanDocument(systemId); } catch(const OutOfMemoryException&) { PAR_XMLDOMParser::parseFile(char *) [E:\develop\program\source\= xmlwrapper.cxx:378] try { transcodexmlch =3D XMLString::transcode(filename); =3D> _parser->parse(transcodexmlch); XMLString::release(&transcodexmlch); } catch(const XMLException& toCatch) Any help is appreciated. With kind regards, Mario Freimann --_000_9B5859DE1377F64794DCB6C5483C058E0731E66970WW001E1ERLMM0_--