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 Lenny Hoffman <le...@earthlink.net> on 2002/04/01 18:19:59 UTC

RE: IDOM: increasing memory

Hi Markus,

As far as I can tell from looking at the code, you have exposed a real
problem with the IDOM storage allocator/memory management scheme.  The
memory for any removed nodes, not just attribute nodes, are not released
until the document is destroyed.  Please submit a bug report in Bugzilla so
that this can be tracked.

Regards,

Lenny

-----Original Message-----
From: Markus Fellner [mailto:fellner@gimbio.de]
Sent: Thursday, March 28, 2002 9:59 AM
To: xerces-c-dev@xml.apache.org
Subject: IDOM: increasing memory


I'm using an IDOM document as an internal data structure in my application.
The code overwrites the value of some attributes many times. The problem is,
that the memory of my application increases very fast.

For simulation of this problem, i use the following code

void test()
{
	XMLPlatformUtils::Initialize();

	XMLCh tempStr[4000];
	XMLCh tempStr2[4000];
	XMLCh tempStr3[4000];
	XMLString::transcode("status", tempStr, 3999);
	XMLString::transcode("true", tempStr2, 3999);
	XMLString::transcode("root", tempStr3, 3999);

	//create document
	IDOM_Document*  cpXMLDocument;
	cpXMLDocument =
IDOM_DOMImplementation::getImplementation()->createDocument();
	//create root element
	IDOM_Element*   cpRoot = cpXMLDocument->createElement(tempStr3);
	//create status attribute
	cpRoot->setAttribute(tempStr,tempStr2);
	IDOM_Attr* pAttr = cpRoot->getAttributeNode(tempStr);

	//simulate setting the attribute value
	for(int i=0;i<200000;i++)
	{
		pAttr->setValue(tempStr2);
		//same problem
		//cpRoot->removeAttribute(tempStr);
		//cpRoot->setAttribute(tempStr,tempStr2);
	}
	delete cpXMLDocument;

	XMLPlatformUtils::Terminate();
	cout << "the end" << endl;
}

my application grows up to 12 MB.

Am I right, that the allocated memory for changed attributes will
be deallocated only at deletion of the whole document?
Is there any chance to get the memory of removed/changed attributes back
without
deleting the whole document?

Thanks!

markus

+----------------------------------------------+
|                                              |
|  |\/\/\/|         M a r k u s  F e l l n e r |
|  |      |                      Plecherstr. 6 |
|  C-(o)(o)                      81541 München |
|  |      _)            Mobil: +49-170-5339667 |
|  | ,___|                Tel: +49-89-6514699  |
|  |    /                 Fax: +49-89-69372952 |
|  /____\       mailto:markus.fellner@epost.de |
|                                              |
+----------------------------------------------+



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


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


RE: IDOM: increasing memory

Posted by Erik Rydgren <er...@mandarinen.se>.
There is a "nasty" work-around.

Create a new document.
Import whole structure.
Delete old document.

Not very efficient but you can use it to clean up the mess when you need the
memory back.

Regards

Erik Rydgren
Mandarinen systems AB
Sweden


-----Original Message-----
From: Lenny Hoffman [mailto:lennyhoffman@earthlink.net]
Sent: den 1 april 2002 18:20
To: xerces-c-dev@xml.apache.org
Subject: RE: IDOM: increasing memory


Hi Markus,

As far as I can tell from looking at the code, you have exposed a real
problem with the IDOM storage allocator/memory management scheme.  The
memory for any removed nodes, not just attribute nodes, are not released
until the document is destroyed.  Please submit a bug report in Bugzilla so
that this can be tracked.

Regards,

Lenny

-----Original Message-----
From: Markus Fellner [mailto:fellner@gimbio.de]
Sent: Thursday, March 28, 2002 9:59 AM
To: xerces-c-dev@xml.apache.org
Subject: IDOM: increasing memory


I'm using an IDOM document as an internal data structure in my application.
The code overwrites the value of some attributes many times. The problem is,
that the memory of my application increases very fast.

For simulation of this problem, i use the following code

void test()
{
	XMLPlatformUtils::Initialize();

	XMLCh tempStr[4000];
	XMLCh tempStr2[4000];
	XMLCh tempStr3[4000];
	XMLString::transcode("status", tempStr, 3999);
	XMLString::transcode("true", tempStr2, 3999);
	XMLString::transcode("root", tempStr3, 3999);

	//create document
	IDOM_Document*  cpXMLDocument;
	cpXMLDocument =
IDOM_DOMImplementation::getImplementation()->createDocument();
	//create root element
	IDOM_Element*   cpRoot = cpXMLDocument->createElement(tempStr3);
	//create status attribute
	cpRoot->setAttribute(tempStr,tempStr2);
	IDOM_Attr* pAttr = cpRoot->getAttributeNode(tempStr);

	//simulate setting the attribute value
	for(int i=0;i<200000;i++)
	{
		pAttr->setValue(tempStr2);
		//same problem
		//cpRoot->removeAttribute(tempStr);
		//cpRoot->setAttribute(tempStr,tempStr2);
	}
	delete cpXMLDocument;

	XMLPlatformUtils::Terminate();
	cout << "the end" << endl;
}

my application grows up to 12 MB.

Am I right, that the allocated memory for changed attributes will
be deallocated only at deletion of the whole document?
Is there any chance to get the memory of removed/changed attributes back
without
deleting the whole document?

Thanks!

markus

+----------------------------------------------+
|                                              |
|  |\/\/\/|         M a r k u s  F e l l n e r |
|  |      |                      Plecherstr. 6 |
|  C-(o)(o)                      81541 München |
|  |      _)            Mobil: +49-170-5339667 |
|  | ,___|                Tel: +49-89-6514699  |
|  |    /                 Fax: +49-89-69372952 |
|  /____\       mailto:markus.fellner@epost.de |
|                                              |
+----------------------------------------------+



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


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


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