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 "Stewart, Daniel J" <da...@boeing.com> on 2002/12/19 20:01:47 UTC

Clarification needed on DOM memory management

The documentation at
http://xml.apache.org/xerces-c/program-dom.html#DOMMemMgmt  says: 

"Memory for any returned object are owned by implementation." 


Also, the documentation at
http://xml.apache.org/xerces-c/ApacheDOMC++BindingL2.html says: 

"
C++ Memory Management: 
	1. A member method "release()" is added for releasing any "orphaned"
resources that were created through createXXXX factory method. 
	2. Memory for any returned object e.g. 
		*DOMNodeList* getChildNodes() 
		*DOMNodeList* getElementsByTagName() 
		*NamedNodeMap* getEntities() 
		*... etc. 
		*are owned by implementation 

"

I have two questions: 
1. Does "implementation" mean *my* application code or does it mean the
Xerces developed DOM implementation? 
2. Would the list of methods that return an object owned by implementation
include DOMNode* getFirstChild()?  Asked another way, is my application
responsible for deleting the DOMNode returned by getFirstChild()? 


Dan Stewart 




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Clarification needed on DOM memory management

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi Dan,

> I have two questions: 
> 1. Does "implementation" mean *my* application code or does it mean the
> Xerces developed DOM implementation? 

If you do not do anything then the document will delete all the allocated 
memory when it is deleted (As long as you have not adopted the document).


> 2. Would the list of methods that return an object owned by implementation
> include DOMNode* getFirstChild()?  Asked another way, is my application
> responsible for deleting the DOMNode returned by getFirstChild()? 


No. You can call release on nodes you know are orphaned. This will signal 
the document that it can reuse the memory from that node.


For a more full explanation have a hunt in the archives. I described the 
model in more depth a month or two ago.


Gareth

-- 
Gareth Reakes, Head of Product Development  +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org