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 Hua-Ying Ling <hy...@gmail.com> on 2004/10/18 20:10:38 UTC
DOMTreeWalker Memory Management
Hi,
I find that if I run the code below in a tight loop, the memory
footprint will keep growing unless I call document->release(). Is
this expected behavior or it is a leak? If this is expected behavior
is it possible to ask Xerces to release unused memory without having
to reparse the xml file?
DOMNode* node = someNode;
DOMTreeWalker *walker;
DOMDocument *document = parser->getDocument();
walker = document->createTreeWalker(node, DOMNodeFilter::SHOW_ELEMENT,
NULL, false);
walker->release();
Thanks
Hua-Ying
--
Gmail Rocks! Ask me for a invite.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: DOMTreeWalker Memory Management
Posted by Gareth Reakes <ga...@parthenoncomputing.com>.
Hi,
> I've tried option 1 and it's at least 3-4 times slower.
> Would you
> give me details and pointers on how to implement option 2? Not sure
> what you meant by implement the release, since release() for the
> DOMTreeWalker is already implemented.
Take a look in dom/impl/DOMTreeWalkerImpl.cpp . You will see that there
is no code in the release method. Then take a look at the code in
release in something like DOMElementImpl.cpp. If you trace that through
you will see what needs to be done. Be warned though, after you do this
you will fully understand xerces memory management :)
> Any open source projects you
> would recommend as a good working example of how Xerces should be
> used?
That really depends on what level. If you want to look at a project
that makes extensive use of xerces then take a look at Pathan 2.
>
--
Gareth Reakes, Managing Director Parthenon Computing
+44-1865-811184 http://www.parthcomp.com
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: validating against multiple XSD File
Posted by Endre Magyari <en...@nextra.ro>.
Dear Gareth,
>> <xsd:complexType name="ruleType">
>> <xsd:sequence minOccurs="0" maxOccurs="unbounded">
>> <xsd:element ref="mathType" minOccurs="0"/>
>> </xsd:sequence>
>> </xsd:complexType>
>>
>
> You need to declare a prefix that binds to the uri for mathType and
> reference it via that.
The prefix has been declared:
xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.isis.vanderbilt.edu/2004/schemas/sbml"
xmlns:sbml="http://www.isis.vanderbilt.edu/2004/schemas/sbml"
xmlns:math="http://www.isis.vanderbilt.edu/2004/schemas/math"
elementFormDefault="qualified">
I have tried to reference it via the prefix 'math', too:
<xsd:element ref="math:mathType" minOccurs="0"/>
But then the error is:
C:\temp\zsolt\SBMLValidator>c:\MobiesTransition\Udm\3rdParty\xerces\xerces-c_2_5
_0-windows_nt-msvc_60\bin\PParse.exe -v=always -n -s -f test_sbml.xml
Error at file C:\temp\zsolt\SBMLValidator/test_sbml.xsd, line 384, char 52
Message: Type not found in
http://www.isis.vanderbilt.edu/2004/schemas/math:ma
thType
Error at file C:\temp\zsolt\SBMLValidator/test_sbml.xsd, line 384, char 52
Message: Ref element math:mathType not found in the Schema
Error at file C:\temp\zsolt\SBMLValidator/test_sbml.xml, line 12, char 6
Message: No character data is allowed by content model
Even if the Math.xsd schema contains the mathType complextype:
<?xml version="1.0" encoding="UTF-8"?>
<?udm interface="SBML2" version="1.00"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.isis.vanderbilt.edu/2004/schemas/math"
xmlns:math="http://www.isis.vanderbilt.edu/2004/schemas/sbml"
elementFormDefault="qualified">
<!-- generated on Tue Nov 09 14:25:35 2004 -->
<xsd:complexType name="mathType">
<xsd:sequence>
<xsd:element name="times" type="timesType" minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="_id" type="xsd:ID"/>
<xsd:attribute name="_archetype" type="xsd:IDREF"/>
<xsd:attribute name="_derived" type="xsd:IDREFS"/>
<xsd:attribute name="_instances" type="xsd:IDREFS"/>
<xsd:attribute name="_desynched_atts" type="xsd:string"/>
<xsd:attribute name="_real_archetype" type="xsd:boolean"/>
<xsd:attribute name="_subtype" type="xsd:boolean"/>
</xsd:complexType>
.....
What am I Missing?
Thank you for your help,
Magyari Endre
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: validating against multiple XSD File
Posted by Gareth Reakes <ga...@parthenoncomputing.com>.
Hi,
On 14 Nov 2004, at 20:29, Endre Magyari wrote:
>
> <xsd:complexType name="ruleType">
> <xsd:sequence minOccurs="0" maxOccurs="unbounded">
> <xsd:element ref="mathType" minOccurs="0"/>
> </xsd:sequence>
> </xsd:complexType>
>
You need to declare a prefix that binds to the uri for mathType and
reference it via that.
EG
> <xsd:complexType name="ruleType"
> xmlns:math="http://www.isis.vanderbilt.edu/2004/schemas/math" >
> <xsd:sequence minOccurs="0" maxOccurs="unbounded">
> <xsd:element ref="math:mathType" minOccurs="0"/>
> </xsd:sequence>
> </xsd:complexType>
Gareth
--
Gareth Reakes, Managing Director Parthenon Computing
+44-1865-811184 http://www.parthcomp.com
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
validating against multiple XSD File
Posted by Endre Magyari <en...@nextra.ro>.
Dear List,
I am trying to validate an XML file using two namespaces, each having a
separate XSD file.
I'd like to have stg like this in the XML file:
<sbml:listOfRules>
<sbml:rule>
<math:math>
<math:apply>
<math:times/>
</math:apply>
</sbml:math>
</sbml:rule>
The question is, how to define the sbml:ruleType complexType, defintion
which should allow containg the math:mathType element.
I have tried to include math.xsd in sbml.xsd like this:
In <schema> element:
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.isis.vanderbilt.edu/2004/schemas/sbml"
xmlns:sbml="http://www.isis.vanderbilt.edu/2004/schemas/sbml"
xmlns:math="http://www.isis.vanderbilt.edu/2004/schemas/math"
elementFormDefault="qualified">
The import statement:
<!-- importing the math namespace -->
<xsd:import namespace="http://www.isis.vanderbilt.edu/2004/schemas/math"
schemaLocation="math.xsd"/>
And an attempt to define ruleType:
<xsd:complexType name="ruleType">
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="mathType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
But unfortunatly the parsing fails:
C:\temp\zsolt\SBMLValidator>c:\MobiesTransition\Udm\3rdParty\xerces\xerces-c_2_5
_0-windows_nt-msvc_60\bin\PParse.exe -v=always -n -s -f test_sbml.xml
Error at file C:\temp\zsolt\SBMLValidator/test_sbml.xsd, line 384, char 47
Message: Schema Representation Constraint: Namespace '' is referenced
without
<import> declaration
Error at file C:\temp\zsolt\SBMLValidator/test_sbml.xsd, line 384, char 47
Message: Ref element mathType not found in the Schema
Error at file C:\temp\zsolt\SBMLValidator/test_sbml.xml, line 12, char 6
Message: No character data is allowed by content model
Any thoughts?
Thanks,
Magyari Endre
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: DOMTreeWalker Memory Management
Posted by Hua-Ying Ling <hy...@gmail.com>.
Gareth,
On Wed, 20 Oct 2004 10:11:48 +0100, Gareth Reakes
<ga...@parthenoncomputing.com> wrote:
> Three options spring to mind:
>
> i) Clone the document into another document and release the first
> (although memory consumption is still an issue with 2 docs in memory)
> ii) Implement the release
> iii) Implement a new memory scheme that actually allows releasing of memory.
>
> iii is the most interesting :) I have thought about it in the past, but
> its a lot of work. I would stick with ii, its not too much work and its
> fairly strait forward. I would be happy to give you some pointers if you
> get stuck.
I've tried option 1 and it's at least 3-4 times slower. Would you
give me details and pointers on how to implement option 2? Not sure
what you meant by implement the release, since release() for the
DOMTreeWalker is already implemented. Any open source projects you
would recommend as a good working example of how Xerces should be
used?
Thanks
Hua-Ying
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: DOMTreeWalker Memory Management
Posted by Gareth Reakes <ga...@parthenoncomputing.com>.
Hey,
Hua-Ying Ling wrote:
>On Tue, 19 Oct 2004 10:15:06 +0100, Gareth Reakes
><ga...@parthenoncomputing.com> wrote:
>
>
>>Hi,
>>
>> this is expected behavior. The rational is that recycling the
>>pointer/memory is expensive in comparison to the likelihood of it being
>>required.
>>
>>
>
>That explains it. I've got a program where I'm accessing the the xml
>file throughout the entire runtime of program. The problem I'm running into is
>the memory footprint keeps growing. For a smaller xml file, releasing the
>parser and reparsing would not be a problem but this is a one
>megabyte and growing xml file. Any suggestions on how to approach
>this problem?
>
>
>
Three options spring to mind:
i) Clone the document into another document and release the first
(although memory consumption is still an issue with 2 docs in memory)
ii) Implement the release
iii) Implement a new memory scheme that actually allows releasing of memory.
iii is the most interesting :) I have thought about it in the past, but
its a lot of work. I would stick with ii, its not too much work and its
fairly strait forward. I would be happy to give you some pointers if you
get stuck.
Gareth
--
Gareth Reakes, Managing Director Parthenon Computing
+44-1865-811184 http://www.parthcomp.com
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: DOMTreeWalker Memory Management
Posted by Hua-Ying Ling <hy...@gmail.com>.
On Tue, 19 Oct 2004 10:15:06 +0100, Gareth Reakes
<ga...@parthenoncomputing.com> wrote:
> Hi,
>
> this is expected behavior. The rational is that recycling the
> pointer/memory is expensive in comparison to the likelihood of it being
> required.
That explains it. I've got a program where I'm accessing the the xml
file throughout the entire runtime of program. The problem I'm running into is
the memory footprint keeps growing. For a smaller xml file, releasing the
parser and reparsing would not be a problem but this is a one
megabyte and growing xml file. Any suggestions on how to approach
this problem?
Thanks
Hua-Ying
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: DOMTreeWalker Memory Management
Posted by Gareth Reakes <ga...@parthenoncomputing.com>.
Hi,
this is expected behavior. The rational is that recycling the
pointer/memory is expensive in comparison to the likelihood of it being
required.
Gareth
Hua-Ying Ling wrote:
>Hi,
>I find that if I run the code below in a tight loop, the memory
>footprint will keep growing unless I call document->release(). Is
>this expected behavior or it is a leak? If this is expected behavior
>is it possible to ask Xerces to release unused memory without having
>to reparse the xml file?
>
>DOMNode* node = someNode;
>DOMTreeWalker *walker;
>DOMDocument *document = parser->getDocument();
>
>walker = document->createTreeWalker(node, DOMNodeFilter::SHOW_ELEMENT,
>NULL, false);
>walker->release();
>
>Thanks
>Hua-Ying
>
>
--
Gareth Reakes, Managing Director Parthenon Computing
+44-1865-811184 http://www.parthcomp.com
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org