You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Brad Nicholes <BN...@novell.com> on 2002/09/09 22:41:33 UTC

memory leak in apr_buck_alloc...

     Has anybody else noticed a memory leak when requesting pages less
than 8k?  If I repeatedly request pages less than 8k I have noticed
that
apr_bucket_alloc() calls allocator_alloc() which seems to continuously
malloc() memory rather than finding it in the free list.  The reason
why
is because allocator->max_index seems to always be 0 and contain no
free
nodes.  If I request pages greater than 8k, allocator->max_index
appears
to be 2.  I can't seem to figure out why the bucket allocator passed
in
by apr_bucket_alloc always contains a max_index of 0 on small page
requests.  Any ideas?

thanks,
Brad


Brad Nicholes
Senior Software Engineer
Novell, Inc., the leading provider of Net business solutions
http://www.novell.com 

Re: memory leak in apr_buck_alloc...

Posted by Justin Erenkrantz <je...@apache.org>.
On Mon, Sep 09, 2002 at 02:41:33PM -0600, Brad Nicholes wrote:
>      Has anybody else noticed a memory leak when requesting pages less
> than 8k?  If I repeatedly request pages less than 8k I have noticed
> that

Yeah, my recent commit to core_output_filter seems to have fixed
this for me.

We removed the EOS buckets from the brigade, but we never deleted
them.  In order to be cleaned up with the pool, they have to be
in a brigade.  An orphan bucket won't be freed.  -- justin

RE: memory leak in apr_buck_alloc...

Posted by Sander Striker <st...@apache.org>.
> From: Bill Stoddard [mailto:bill@wstoddard.com]
> Sent: 10 September 2002 22:23

>> [Moving to dev@apr.apache.org]

[...]
>> I think max_index is misunderstood.  allocator->max_index is the index of
>> the biggest block available.  index = block_size / boundary_size - 1, where
>> boundary_size is 4096.  Keeping track of max_index prevents us from scanning
>> the entire array of free lists (of different block sizes).
> 
> Code comment pretty please? I spent a very small bit of time in the
> allocator code a few months back and gave up :-)

Point taken.  Will do.

Sander


RE: memory leak in apr_buck_alloc...

Posted by Bill Stoddard <bi...@wstoddard.com>.
> [Moving to dev@apr.apache.org]
>
> > From: Cliff Woolley [mailto:jwoolley@virginia.edu]
> > Sent: 09 September 2002 22:42
>
> > On Mon, 9 Sep 2002, Brad Nicholes wrote:
> >
> > >      Has anybody else noticed a memory leak when requesting pages less
> > > than 8k?  If I repeatedly request pages less than 8k I have
> noticed that
> > > apr_bucket_alloc() calls allocator_alloc() which seems to continuously
> > > malloc() memory rather than finding it in the free list.  The
> reason why
> > > is because allocator->max_index seems to always be 0 and
> contain no free
> > > nodes.  If I request pages greater than 8k,
> allocator->max_index appears
> > > to be 2.  I can't seem to figure out why the bucket allocator
> passed in
> > > by apr_bucket_alloc always contains a max_index of 0 on small page
> > > requests.  Any ideas?
> >
> > Ughuuhhhhhh ... good question!  I'll let Sander take a stab at that one
> > before I try to dig in and see what's going on... but I will do so if no
> > answers are forthcoming in the near-term.
>
> I think max_index is misunderstood.  allocator->max_index is the index of
> the biggest block available.  index = block_size / boundary_size
> - 1, where
> boundary_size is 4096.  Keeping track of max_index prevents us
> from scanning
> the entire array of free lists (of different block sizes).

Code comment pretty please? I spent a very small bit of time in the
allocator code a few months back and gave up :-)

Bill


RE: memory leak in apr_buck_alloc...

Posted by Sander Striker <st...@apache.org>.
[Moving to dev@apr.apache.org]

> From: Cliff Woolley [mailto:jwoolley@virginia.edu]
> Sent: 09 September 2002 22:42

> On Mon, 9 Sep 2002, Brad Nicholes wrote:
> 
> >      Has anybody else noticed a memory leak when requesting pages less
> > than 8k?  If I repeatedly request pages less than 8k I have noticed that
> > apr_bucket_alloc() calls allocator_alloc() which seems to continuously
> > malloc() memory rather than finding it in the free list.  The reason why
> > is because allocator->max_index seems to always be 0 and contain no free
> > nodes.  If I request pages greater than 8k, allocator->max_index appears
> > to be 2.  I can't seem to figure out why the bucket allocator passed in
> > by apr_bucket_alloc always contains a max_index of 0 on small page
> > requests.  Any ideas?
> 
> Ughuuhhhhhh ... good question!  I'll let Sander take a stab at that one
> before I try to dig in and see what's going on... but I will do so if no
> answers are forthcoming in the near-term.

I think max_index is misunderstood.  allocator->max_index is the index of
the biggest block available.  index = block_size / boundary_size - 1, where
boundary_size is 4096.  Keeping track of max_index prevents us from scanning
the entire array of free lists (of different block sizes).

Anyhow, I'm still investigating.  Haven't found the/a problem yet in the code.
But then again, I might be missing the obvious.  Extra eyes welcome.


Sander

RE: memory leak in apr_buck_alloc...

Posted by Sander Striker <st...@apache.org>.
> From: Cliff Woolley [mailto:jwoolley@virginia.edu]
> Sent: 09 September 2002 22:42

> On Mon, 9 Sep 2002, Brad Nicholes wrote:
> 
> >      Has anybody else noticed a memory leak when requesting pages less
> > than 8k?  If I repeatedly request pages less than 8k I have noticed that
> > apr_bucket_alloc() calls allocator_alloc() which seems to continuously
> > malloc() memory rather than finding it in the free list.  The reason why
> > is because allocator->max_index seems to always be 0 and contain no free
> > nodes.  If I request pages greater than 8k, allocator->max_index appears
> > to be 2.  I can't seem to figure out why the bucket allocator passed in
> > by apr_bucket_alloc always contains a max_index of 0 on small page
> > requests.  Any ideas?
> 
> Ughuuhhhhhh ... good question!  I'll let Sander take a stab at that one
> before I try to dig in and see what's going on... but I will do so if no
> answers are forthcoming in the near-term.

I'll give it a look tomorrow.  I've got a pretty decent hunch on what is
going on...

Sander


RE: memory leak in apr_buck_alloc...

Posted by Sander Striker <st...@apache.org>.
> From: Cliff Woolley [mailto:jwoolley@virginia.edu]
> Sent: 09 September 2002 22:42

> On Mon, 9 Sep 2002, Brad Nicholes wrote:
> 
> >      Has anybody else noticed a memory leak when requesting pages less
> > than 8k?  If I repeatedly request pages less than 8k I have noticed that
> > apr_bucket_alloc() calls allocator_alloc() which seems to continuously
> > malloc() memory rather than finding it in the free list.  The reason why
> > is because allocator->max_index seems to always be 0 and contain no free
> > nodes.  If I request pages greater than 8k, allocator->max_index appears
> > to be 2.  I can't seem to figure out why the bucket allocator passed in
> > by apr_bucket_alloc always contains a max_index of 0 on small page
> > requests.  Any ideas?
> 
> Ughuuhhhhhh ... good question!  I'll let Sander take a stab at that one
> before I try to dig in and see what's going on... but I will do so if no
> answers are forthcoming in the near-term.

I'll give it a look tomorrow.  I've got a pretty decent hunch on what is
going on...

Sander


RE: memory leak in apr_buck_alloc...

Posted by Sander Striker <st...@apache.org>.
[Moving to dev@apr.apache.org]

> From: Cliff Woolley [mailto:jwoolley@virginia.edu]
> Sent: 09 September 2002 22:42

> On Mon, 9 Sep 2002, Brad Nicholes wrote:
> 
> >      Has anybody else noticed a memory leak when requesting pages less
> > than 8k?  If I repeatedly request pages less than 8k I have noticed that
> > apr_bucket_alloc() calls allocator_alloc() which seems to continuously
> > malloc() memory rather than finding it in the free list.  The reason why
> > is because allocator->max_index seems to always be 0 and contain no free
> > nodes.  If I request pages greater than 8k, allocator->max_index appears
> > to be 2.  I can't seem to figure out why the bucket allocator passed in
> > by apr_bucket_alloc always contains a max_index of 0 on small page
> > requests.  Any ideas?
> 
> Ughuuhhhhhh ... good question!  I'll let Sander take a stab at that one
> before I try to dig in and see what's going on... but I will do so if no
> answers are forthcoming in the near-term.

I think max_index is misunderstood.  allocator->max_index is the index of
the biggest block available.  index = block_size / boundary_size - 1, where
boundary_size is 4096.  Keeping track of max_index prevents us from scanning
the entire array of free lists (of different block sizes).

Anyhow, I'm still investigating.  Haven't found the/a problem yet in the code.
But then again, I might be missing the obvious.  Extra eyes welcome.


Sander

Re: memory leak in apr_buck_alloc...

Posted by Cliff Woolley <jw...@virginia.edu>.
On Mon, 9 Sep 2002, Brad Nicholes wrote:

>      Has anybody else noticed a memory leak when requesting pages less
> than 8k?  If I repeatedly request pages less than 8k I have noticed that
> apr_bucket_alloc() calls allocator_alloc() which seems to continuously
> malloc() memory rather than finding it in the free list.  The reason why
> is because allocator->max_index seems to always be 0 and contain no free
> nodes.  If I request pages greater than 8k, allocator->max_index appears
> to be 2.  I can't seem to figure out why the bucket allocator passed in
> by apr_bucket_alloc always contains a max_index of 0 on small page
> requests.  Any ideas?

Ughuuhhhhhh ... good question!  I'll let Sander take a stab at that one
before I try to dig in and see what's going on... but I will do so if no
answers are forthcoming in the near-term.

--Cliff