apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cliff Woolley <cliffwool...@yahoo.com>
Subject Re: Observations on fragmentation in SMS pools
Date Sun, 08 Jul 2001 17:11:58 GMT
On Sun, 8 Jul 2001, Ian Holsman wrote:

> I was wondering why the brigade code doesn't make use of pools/sms  to
> handle it's memory.
> It has a pool passed to it from what I can see...

The brigade is allocated out of a pool, and that pool is used to register
a cleanup on the brigade to make sure all of the buckets in that brigade
get destroyed.

The buckets themselves use malloc(). The buckets do not and cannot use
pools because the lifetimes could get to be all wrong pretty easily, and
it could be a _major_ resource leak on big requests or pipelined
connections. I'm in the process of switching them to use apr_sms_malloc().
I've got a 3-phase plan for making that switchover and have written phase
1, which I just need to test and commit.

The three phases go something like this (I might have mentioned this on
the list before... I can't remember whether I did or not, so here it is

Phase 1: s/malloc/apr_sms_malloc/g; s/free/apr_sms_free/g; Add in a global
         apr_sms_std instance in the buckets code that all buckets will
         use to get their memory from.  Add an apr_sms_t* to the
         apr_bucket struct so that the apr_bucket_foo_make() functions
         know which SMS to use when allocating memory for private
         structures.  Set that pointer to reference the global
         apr_sms_std instance in all of the apr_bucket_foo_create()
         functions for now.

Phase 2: Add an apr_sms_t parameter to all apr_bucket_foo_create()
         functions that lets the caller determine which SMS to use.
         For now, they can all just pass in a pointer to the global
         apr_sms_std instance.

Phase 3: Create a per-thread blocks SMS in the Apache MPM's and
         stash a pointer to it in the conn_rec for each request.
         Use that instead of the global apr_sms_std when creating
         all buckets and get rid of the global apr_sms_std.


   Cliff Woolley
   Charlottesville, VA

View raw message