Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 18th, 2006, 10:35 PM
polism@gmail.com
Guest
 
Posts: n/a
Default importNode() / release() memory growth problem in Xerces-C++

Hi,
I have the following simple code, using xerces running on my windows.
This demo compiles and runs normally, but when I open my Task Manager,
I see a constant memory growth of my process, and I dont understand
why.

//***********************************************
XMLPlatformUtils::Initialize();
DOMImplementation impl =
DOMImplementationRegistry::getDOMImplementation(.. .);
DOMDocument* doc1 = impl->createDocument(...);
DOMDocument* doc2 = impl->createDocument(...);
DOMElement* elem1 = doc1->createElement(...);
DOMElement* elem2 = doc2->createElement(...);

// get elem2 to be realy big element, so that memory leak will be more
visible
DOMElement* tmp = doc2->createElement(...);
for(int i=0; i<50; i++)
{
elem2->appendChild(tmp);
}

DOMNode* node;
while(true)
{
// thread sleep for 20 msec
Sleep(20);
node = doc1->importNode(elem2, true);
node->release();
}


//************************************************** **
I understand that importNode() actualy clones the original node, but
release() is supposed to free it, and it seems that it doesn't happen.
What is wrong here? please help.

thanx ahead,
Mike

  #2  
Old December 19th, 2006, 01:25 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: importNode() / release() memory growth problem in Xerces-C++

polism@gmail.com wrote:
Quote:
// get elem2 to be realy big element, so that memory leak will be more
visible
DOMElement* tmp = doc2->createElement(...);
for(int i=0; i<50; i++)
{
elem2->appendChild(tmp);
}
You have just one tmp element that you append fifty times to the same
elem2 so I am not sure why that makes elem2 really big.

Not sure a about the memory issue, you might want to ask on the Xerces
C++ mailing list.


--

Martin Honnen
http://JavaScript.FAQTs.com/
  #3  
Old December 20th, 2006, 06:15 AM
polism@gmail.com
Guest
 
Posts: n/a
Default Re: importNode() / release() memory growth problem in Xerces-C++

well, every time you appendChild, the child is added, even if it is
pointer to the same object.

Mike


Martin Honnen wrote:
Quote:
polism@gmail.com wrote:
>
Quote:
// get elem2 to be realy big element, so that memory leak will be more
visible
DOMElement* tmp = doc2->createElement(...);
for(int i=0; i<50; i++)
{
elem2->appendChild(tmp);
}
>
You have just one tmp element that you append fifty times to the same
elem2 so I am not sure why that makes elem2 really big.
>
Not sure a about the memory issue, you might want to ask on the Xerces
C++ mailing list.
>
>
--
>
Martin Honnen
http://JavaScript.FAQTs.com/
  #4  
Old December 20th, 2006, 01:15 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: importNode() / release() memory growth problem in Xerces-C++

polism@gmail.com wrote:
Quote:
well, every time you appendChild, the child is added, even if it is
pointer to the same object.
If you have just one node you pass to appendChild fifty times then the
node you can appendChild on will have just one child node appended. So
it suffices to call appendChild once, doing it several times does not
add more children, unless you created a new node to be passed in each time.

--

Martin Honnen
http://JavaScript.FAQTs.com/
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles