Hi Peoyong,
Thanks for quick reply. Aslo thanks for putting in the fix for the memory leak about the fHeadNode. But I still don't understand what do you means the qname has been fix in previous version. I checked version 1.4.0 and 1.5.1. There are not delete qname there. The the newest nightly build (2001-08-14), I did find delete qname at the end of buildDFA(), but also I found delete fHeadNode statement has been comment out. In this case, does it mean qname memory leak problem has been fixed, but not fHeadNode's?? I cut and past the source code as following...
// Adding any of the following three deletes will
// cause "Unexpected exception during parsing ..." error.
//
// delete fHeadNode;
// delete nodeOrgContent;
// delete nodeEOC;
What does it mean for "Unexpected exception during parsing"? Do you have the paticular sample for XML file or code will make this exception happen? If you do, please let me know. Thanks.
Regards,
Nick Chiang
PS: I'm running Xerces-C on SUN Solaris 2.7. I found those memory leak by using Purify.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 17, 2001 12:27 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: memory leaks in Xerces-C++ 1.5.0 version
Nick,
The reported memory leak about the --qname-- had been solved in
the previous version, the actual "delete qname" is located at the
end of the function buildDFA().
The leak related to --fHeadNode-- has been verified and *your fix*
has been applied and tested against BoundsChecker, no more memory
leak regarding fHeadNode, good job, thanks.
The revised version of DFAContentModel is available from apache.
Regards,
Peiyong Zhang
____________________________________________
XML Parsers Development
IBM Toronto Laboratory email: [EMAIL PROTECTED]
Phone: (416)448-4088; Fax: (416)448-4414; T/L: 778-4088
Nick Chiang <[EMAIL PROTECTED]> on 08/16/2001 03:54:33 PM
Please respond to [EMAIL PROTECTED]
To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
cc: Ron Ho <[EMAIL PROTECTED]>, Michael Tsu <[EMAIL PROTECTED]>
Subject: memory leaks in Xerces-C++ 1.5.0 version
Hi,
I found two places may have memory leak problem.
First, in src/validators/common/DFAContentModel.cpp Line 464
function DFAContentModel::buildDFA().
statement:
QName* qname = new QName(XMLUni::fgZeroLenString,
XMLUni::fgZeroLenString, XMLContentModel::gEOCFakeId);
This needs to be freed after the next statement (CMLeaf* nodeEOC =
new CMLeaf(qname);).
Original Source Code:
QName* qname = new QName(XMLUni::fgZeroLenString,
XMLUni::fgZeroLenString, XMLContentModel::gEOCFakeId);
CMLeaf* nodeEOC = new CMLeaf(qname);
To fix the memory leak:
QName* qname = new QName(XMLUni::fgZeroLenString,
XMLUni::fgZeroLenString, XMLContentModel::gEOCFakeId);
CMLeaf* nodeEOC = new CMLeaf(qname);
delete qname;
Second, in src/validators/common/DFAContentModel.cpp Line 837.
fHeadNode has to be deleted, since delete 'fLeafList' only remove the
leaves in the tree. The other node such as CMAny, CMBinaryOp and CMUnaryOp
won't be freed. In order to correct this problem there are some codes need
to be change.
Line: 836 Orig Code DFAContentModel.cpp
//delete fHeadNode;
fHeadNode = 0;
New Code
delete fHeadNode;
//fHeadNode = 0;
Line: 1046 Orig Code DFAContentModel.cpp
fLeafList[newIndex] = (CMLeaf*)nodeCur;
New Code
fLeafList[newIndex] = new CMLeaf(((CMLeaf*)nodeCur)->getElement(),
((CMLeaf*)nodeCur)->getPosition
());
Regards,
Nick Chiang
PS: If you plan to fix the problem in future release, would you mind to let
me know the release number. Thanks.
