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 jiang lei <ji...@8107.co.jp> on 2003/07/04 02:53:06 UTC

DOMNodeList memory allocation?

Hi everybody,

Everytime I use the method DOMNode::getElementsByTagname() I am quite
worried about the memory allocation. That method returns a pointer to
DOMNodeList, which stores node pointers in a temporary place.

So it came to me like there are possibly 2  pattern for the making of  a
DOMNodeList:

1. the newly created DOMNodeList takes memory from a memory pool or register
itself to a memory manager. When the node or document is released,
corresponding DOMNodeList will be destructed as well.

2. there can only be 1 instance of a DOMNodeList at a time for each DOMNode.
Each time you use getElementsByTagname(), the old will be gone and a new
list will be created in its place.

Am I right? Or is there another pattern?

Thanks a lot for your attention.

Best Regards

Lei


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


Re: DOMNodeList memory allocation?

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
	the lists themselves are only released when the document is 
released. They are however cached based on the root node, name and 
namespace.

Gareth

On Tue, 8 Jul 2003, jiang lei wrote:

> Hi Gareth,
> 
> Thanks for your answer.
> 
> My question was about the memory allocation of DOMNodeList itself.
> As I use DOMNode::getElementsByTagname() a  lot, sometimes even in a loop,
> what I am concerning indeed is when the LIST will be released. So after I
> post my question I created a test program to see how much memory it will
> take to call getElementsByTagname() for 10000 times. The result is quite
> satisfying and I don't worry about it anymore. However, I'm still quite
> interested in how it is done.
> 
> Best Regards
> 
> Lei
> 
> ----- Original Message -----
> From: "Gareth Reakes" <ga...@decisionsoft.com>
> To: <xe...@xml.apache.org>
> Sent: Monday, July 07, 2003 6:14 PM
> Subject: Re: DOMNodeList memory allocation?
> 
> 
> > Hi,
> > the nodes point to each other and so there is not a large storage
> > of node pointers in a container. Is this the information you want?
> >
> > Gareth
> >
> >
> > On Fri, 4 Jul 2003, jiang lei wrote:
> >
> > > Hi everybody,
> > >
> > > Everytime I use the method DOMNode::getElementsByTagname() I am quite
> > > worried about the memory allocation. That method returns a pointer to
> > > DOMNodeList, which stores node pointers in a temporary place.
> > >
> > > So it came to me like there are possibly 2  pattern for the making of  a
> > > DOMNodeList:
> > >
> > > 1. the newly created DOMNodeList takes memory from a memory pool or
> register
> > > itself to a memory manager. When the node or document is released,
> > > corresponding DOMNodeList will be destructed as well.
> > >
> > > 2. there can only be 1 instance of a DOMNodeList at a time for each
> DOMNode.
> > > Each time you use getElementsByTagname(), the old will be gone and a new
> > > list will be created in its place.
> > >
> > > Am I right? Or is there another pattern?
> > >
> > > Thanks a lot for your attention.
> > >
> > > Best Regards
> > >
> > > Lei
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> > >
> > >
> > >
> >
> > --
> > Gareth Reakes, Head of Product Development  +44-1865-203192
> > DecisionSoft Limited                        http://www.decisionsoft.com
> > XML Development and Services
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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
> 
> 
> 

-- 
Gareth Reakes, Head of Product Development  +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services




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


Re: DOMNodeList memory allocation?

Posted by jiang lei <ji...@8107.co.jp>.
Hi Gareth,

Thanks for your answer.

My question was about the memory allocation of DOMNodeList itself.
As I use DOMNode::getElementsByTagname() a  lot, sometimes even in a loop,
what I am concerning indeed is when the LIST will be released. So after I
post my question I created a test program to see how much memory it will
take to call getElementsByTagname() for 10000 times. The result is quite
satisfying and I don't worry about it anymore. However, I'm still quite
interested in how it is done.

Best Regards

Lei

----- Original Message -----
From: "Gareth Reakes" <ga...@decisionsoft.com>
To: <xe...@xml.apache.org>
Sent: Monday, July 07, 2003 6:14 PM
Subject: Re: DOMNodeList memory allocation?


> Hi,
> the nodes point to each other and so there is not a large storage
> of node pointers in a container. Is this the information you want?
>
> Gareth
>
>
> On Fri, 4 Jul 2003, jiang lei wrote:
>
> > Hi everybody,
> >
> > Everytime I use the method DOMNode::getElementsByTagname() I am quite
> > worried about the memory allocation. That method returns a pointer to
> > DOMNodeList, which stores node pointers in a temporary place.
> >
> > So it came to me like there are possibly 2  pattern for the making of  a
> > DOMNodeList:
> >
> > 1. the newly created DOMNodeList takes memory from a memory pool or
register
> > itself to a memory manager. When the node or document is released,
> > corresponding DOMNodeList will be destructed as well.
> >
> > 2. there can only be 1 instance of a DOMNodeList at a time for each
DOMNode.
> > Each time you use getElementsByTagname(), the old will be gone and a new
> > list will be created in its place.
> >
> > Am I right? Or is there another pattern?
> >
> > Thanks a lot for your attention.
> >
> > Best Regards
> >
> > Lei
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> >
> >
> >
>
> --
> Gareth Reakes, Head of Product Development  +44-1865-203192
> DecisionSoft Limited                        http://www.decisionsoft.com
> XML Development and Services
>
>
>
>
> ---------------------------------------------------------------------
> 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: DOMNodeList memory allocation?

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
	the nodes point to each other and so there is not a large storage 
of node pointers in a container. Is this the information you want?

Gareth


On Fri, 4 Jul 2003, jiang lei wrote:

> Hi everybody,
> 
> Everytime I use the method DOMNode::getElementsByTagname() I am quite
> worried about the memory allocation. That method returns a pointer to
> DOMNodeList, which stores node pointers in a temporary place.
> 
> So it came to me like there are possibly 2  pattern for the making of  a
> DOMNodeList:
> 
> 1. the newly created DOMNodeList takes memory from a memory pool or register
> itself to a memory manager. When the node or document is released,
> corresponding DOMNodeList will be destructed as well.
> 
> 2. there can only be 1 instance of a DOMNodeList at a time for each DOMNode.
> Each time you use getElementsByTagname(), the old will be gone and a new
> list will be created in its place.
> 
> Am I right? Or is there another pattern?
> 
> Thanks a lot for your attention.
> 
> Best Regards
> 
> Lei
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 
> 

-- 
Gareth Reakes, Head of Product Development  +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services




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