Hi,
I am doing a project using DOMParser on Solaris workstation, I need to visit
the same XML file repeatedly. To be efficient, I save the root of document
(DOM_Node doc=parser ->getDocument() ) to avoid parsing the document every
time. There are over a thousand XML file so I am worried about the memory
usuage. I experiment this idea with example DOMPrint.
I add red lines in the source code of DOMPrint like below.
int i=0;
int j=0;
DOM_Node myDoc[1000];
bool firstRound = 1;
for (;;)
{
bool errorsOccured = false;
i++;
cerr <<i<<endl;
cerr <<j<<endl;
if ( i == 1000 )
{
firstRound = 0;
i =1;
j++;
}
if (firstRound)
{
try
{
parser->parse(gXmlFile);
}
...
}
// If the parse was successful, output the document data from the DOM
tree
if (!errorsOccured)
{
if (firstRound)
{
DOM_Node doc = parser->getDocument();
myDoc[i] = doc;
}
DOMPrintFormatTarget* formatTarget = new DOMPrintFormatTarget();
if (gEncodingName == 0)
{
DOMString encNameStr("UTF-8");
DOM_Node aNode = myDoc[i].getFirstChild();
...
cout << myDoc[i] << endl;
...
delete formatTarget;
delete gFormatter;
}
} //end of for(;;)
I use sdtprocess to monitor the memory usage, the memory usage goes up and
stays stable after first round, RAM reaches 16304k, SWAP 16744k.
If I just add infinite loop to DOMPrint for monitoring purpose, the RAM is
2504k, SWAP is 2984k.
The XML file is 1098 byte. So almost 16k per file when it is parsed.
My question is
1. Is this symptom ok?
2. It is more important. If I do not want to re-visit the file any more, how
do I free the memory?
In the actual implementation, I have an object associated with each
file, data member is DOM_Node doc of the xml file.
When the file is not in use any more, I delete the object. But I did not
observe any memory freed.
Do you have any idea or suggestion?
Thanks in advance.
-min
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]