httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Bloom <...@raleigh.ibm.com>
Subject Memory Allocation in APR (WAS: local/remote address in conn_rec)
Date Wed, 20 Oct 1999 13:50:29 GMT
> One other thing I noticed. When using ap_accept() in the main loop the new
> sockets created are allocated from the global pool (same pool as the listen
> socket was allocated from) which means it will never be freed, leaking one
> ap_socket_t for every connection. The only way I can see around this is to
> give ap_accept a context to allocate new sockets from instead of using the
> listener's context.

This gives me a chance to bring up my least favorite topic.  Memory
allocation.  :)  We need to finally put this baby to rest, and we need to
do it soon, so I want feedback.  The way I see it, there has been a lot of
I want's, that don't mesh well, and nobody has stepped up to do the work.

I'm stepping up.  I would like everybody to give me their wish list, and
when I get back on NOVEMBER 8th, I will begin to implement a decided upon
memory allocation scheme.

Here are the options I see:

APR doesn't do the memory allocation.  We allocate our own memory which is
then passed into APR functions.  We still need to store a context in the
APR function, because I have no clue when a platform will need to allocate
memory within an APR function.

APR does the memory allocation.  This is the way it is currently done.  We
pass in a context once, and APR uses that context for all memory
allocation for that variable.

Now, for the underlying parts, How do we allocate memory.  These work in
both of the above methods.

1)  One pool per context. ap_palloc, ap_malloc, ap_shalloc(shared memory).
Basically, different allocation functions that all operate on the same
pool in different ways.  Each allocation type would require it's own
cleanup list.

2)  Multiple pools per context.  This is what I originally envisioned when
creating contexts.  Basically, ap_palloc, ap_malloc, and ap_shalloc each
operate on their own pools, and leave the others alone.

3)  Pool and non-pool allocation.  ap_palloc would use pools, ap_malloc
wouldn't exist (we would just use malloc), and ap_shalloc would use Ralf's
MM library (or something like it) to allocate shared memory.

I would appreciate a simple vote, The vote will end on Monday, but I
won't tally the vote or post results until I get back.

HOW TO ALLOCATE:

    [ ] APR allocates the memory   
          If You choose this one:
          APR ALLOCATES MEMORY USING:
              [ ] ap_palloc
              [ ] ap_malloc/ap_free or malloc/free

    [ ] Apache passes pre-allocated memory to APR

HOW TO CONTROL THE ALLOCATION
    
    [ ] One pool per context
    [ ] Multiple pools per context
    [ ] Pool and non-pool allocation

I am sorry the results will take so long, but a series of unfortunate
events has delayed my posting this message, so that now I am posting it
just before I get married, and will be away from the computer for two
weeks.

Ryan


_______________________________________________________________________
Ryan Bloom		rbb@raleigh.ibm.com
4205 S Miami Blvd	
RTP, NC 27709		It's a beautiful sight to see good dancers 
			doing simple steps.  It's a painful sight to
			see beginners doing complicated patterns.	


Mime
View raw message