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 "Stannard, Andrew" <An...@ACNielsen.ca> on 2002/11/11 19:12:21 UTC
Creating and Releasing DOMElements
Hi All,
I tracked a memory leak in a program I am writing down to the equivalent of
the following two lines of code.
DOMElement* newElement = DOMDocument->createElement(X("NodeName"));
newElement->release();
I had assumed that creating and element and subsequently releasing that
element would be memory neutral, however I found when looping those two
lines as a test my memory allocation grows without bound. The string
trancode function is not the problem, I tested that.
Is there another function I could call to delete/clean up an element?
I worked around the problem by creating a new document, copying the contents
over with import, and releasing the old document, but it would be nice to be
able to release a single node.
Thx,
Andrew
Re: Creating and Releasing DOMElements
Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
An element allocates a DOMAttrMapImpl that is not part of the element
and is owned by the document. This will not be released when release is
called. I believe this is what you what you are seeing. I know no way of
releasing this memory without destroying the document.
Gareth
On Mon, 11 Nov 2002, Stannard, Andrew wrote:
> Hi All,
>
> I tracked a memory leak in a program I am writing down to the equivalent of
> the following two lines of code.
>
> DOMElement* newElement = DOMDocument->createElement(X("NodeName"));
> newElement->release();
>
> I had assumed that creating and element and subsequently releasing that
> element would be memory neutral, however I found when looping those two
> lines as a test my memory allocation grows without bound. The string
> trancode function is not the problem, I tested that.
>
> Is there another function I could call to delete/clean up an element?
>
> I worked around the problem by creating a new document, copying the contents
> over with import, and releasing the old document, but it would be nice to be
> able to release a single node.
>
> Thx,
> Andrew
>
--
Gareth Reakes, Head of Product Development
DecisionSoft Ltd. http://www.decisionsoft.com
Office: +44 (0) 1865 203192
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org