[xml] xmlXPathNodeSetAddUnique:out of memory ?
- From: Jasmit Singh <jsingh boulder vni com>
- To: "'xml gnome org'" <xml gnome org>
- Subject: [xml] xmlXPathNodeSetAddUnique:out of memory ?
- Date: Tue, 1 Oct 2002 11:32:36 -0600
Hello,
I am currently working with 100KB xml file and using xpath to query the
file. the //* query works great but when I try to use
/ADDRESSBOOK/PERSON[5]/following::* the xmlxpathNodeSetAddUnique gives me an
out of memory error. The xml file is just a repetition of the text below to
make it 100KB.
The entire tree is returned without a problem but when returning part of the
tree it runs out of memory. Is this the correct behavior?
I did look at the xmlXPathNodeSetAddUnique function in the xpath.c file. I
noticed that the cur->nodeMax was doubled every time and thus when realloc
is done it runs out of memory. The value of cur->nodeNr reached 167772160
before it gave up. In case of querying the entire tree (//*) the
cur->nodeNr value never goes above 10.
Thanks,
Jasmit Singh
LibXml 2.4.23
Solaris 2.7
} else if (cur->nodeNr == cur->nodeMax) {
xmlNodePtr *temp;
cur->nodeMax *= 2;
temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax *
sizeof(xmlNodePtr));
if (temp == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlXPathNodeSetAddUnique: out of memory\n");
return;
}
cur->nodeTab = temp;
}
Note: Just repeat the Person over and over again until 100 KB is reached.
<?xml version= '1.0'?>
<!DOCTYPE ADDRESSBOOK [
<!ELEMENT ADDRESSBOOK (PERSON)*>
<!ELEMENT PERSON (LASTNAME, FIRSTNAME, COMPANY, EMAIL, PHONE)>
<!ELEMENT LASTNAME (#PCDATA)>
<!ELEMENT FIRSTNAME (#PCDATA)>
<!ELEMENT COMPANY (#PCDATA)>
<!ELEMENT EMAIL (#PCDATA)>
<!ELEMENT PHONE (#PCDATA)>
<!ENTITY PHONENUMBER '540-552-7788'>
<!ATTLIST PERSON gender CDATA #IMPLIED>
]>
<ADDRESSBOOK>
<!--new information-->
<PERSON gender='male'>
<LASTNAME>Idris</LASTNAME>
<FIRSTNAME>Namul</FIRSTNAME>
<COMPANY><![CDATA[<<The Bean Factory>>]]></COMPANY>
<EMAIL>xml beanfactory com</EMAIL>
<PHONE>&PHONENUMBER;</PHONE>
</PERSON>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]