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 rc...@micron.com on 2004/03/03 17:50:45 UTC

More release() questions...

Hi All,

I am just getting back to the xerces-c-dev mailing list after a long
time.  I did browse the archives before posting, so sorry if I may have
missed any response on this.

>From what I understand, just releasing element nodes does not free up
the memory until the document node is destroyed. Are there any plans on
changing this behavior? 

We have some applications that need to run 24x7 and constantly add and
delete element nodes and attributes from the DOM.  The behavior that
Xerces has right now is the memory keeps increasing and there is no way
to free up the space.

Is there any workaround for this (short of releasing the document and
recreating it?)

What makes it bad for us is, lots of attributes are created and because
of Bug 13197, they never get deleted either when the element is
released.

In a recent posting, Gareth mentioned he had a detailed description on
memory management to the mailing list a few months back, does anyone
have a link to it?  I could not find that from the archives.


Here is what I am trying to do.... 

/*********************************************************************/
  DOMImplementation* impl =
DOMImplementationRegistry::getDOMImplementation(X("Core"));

        DOMDocument* doc = impl->createDocument(
                    0,                    // root element namespace URI.
                    X("company"),         // root element name
                    0);                   // document type object (DTD).

        DOMElement* rootElem = doc->getDocumentElement();
        
	//Add and remove 100000 nodes, memory keeps increasing 
		for (int i = 0; i < 100000; i++)
		{
			DOMElement*  prodElem =
doc->createElement(X("product"));
			rootElem->appendChild(prodElem);

			//Now remove the child node...
			rootElem->removeChild(prodElem);
                             prodElem->release();
		}
/*********************************************************************/

Any help or pointers would be appreciated,

Thanks,

Ravin