You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Boris Kolpackov <bo...@codesynthesis.com> on 2010/05/25 15:27:01 UTC
Re: Question About xerces code
Hi Henry,
In the future please send questions about Xerces-C++ to one of the
project's mailing lists instead of to me directly. For technical
questions like these c-dev is appropriate (which, BTW, I've CC'ed
to my reply).
Wang, Henry (LeftHand Networks) <he...@hp.com> writes:
> Hi. Boris;
> My name is Henry Wang, I am with HP Corp. We have a project using
> Xerces, and we constantly have memory leak. We use Purify trying to find
> where the leak is. Purify always point to ContentSpecNode constructor is
> leaking memory. I studied the xerces code and have several questions here.
> I appreciate your help in understanding this code. Thanks.
>
> 1. In ContentSpecNode::ContentSpecNode() constructor,
> fElement = new (fMemoryManager) QName(*element);
>
> this does not allocate memory, just replace memory allready allocated
> by FMemoryManager, but then the destructor of ContentSpecNode is:
>
> delete fElement;
>
> This will call Standard Library "delete" function.
>
> Don't we have a mis-match here, the fMemoryManager should be called to
> de-allocate memory, right ?
QName derives from XMemory which overloads operator delete() to free
the memory using the memory manager. See the XMemory implementation
for details.
> 2. In void TraverseSchema::validateAnnotations() {
>
> we have:
>
> ContentSpecNode* left = new (memMgr) ContentSpecNode(appInfoElemDecl, memMgr);
> ContentSpecNode* right = new (memMgr) ContentSpecNode(docElemDecl, memMgr);
> ContentSpecNode* root = new (memMgr) ContentSpecNode(ContentSpecNode::ModelGroupChoice
> , left
> , right
> , true
> , true
> , memMgr);
>
> Does the memMgr smart enough to replace different section of memory
> for these three consective replacements?, How the delete will work?
I am not sure what you mean by these. new (memMgr) ... will allocate
the memory block using the memory manager. operator delete () from
XMemory will release it.
Boris
--
Boris Kolpackov, Code Synthesis http://codesynthesis.com/~boris/blog
Open-source XML data binding for C++ http://codesynthesis.com/products/xsd
XML data binding for embedded systems http://codesynthesis.com/products/xsde
Command line interface to C++ compiler http://codesynthesis.com/projects/cli
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org