You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by David Harris <dh...@drh.net> on 1999/08/04 18:17:31 UTC

[patch] make ap_bytes_in_pool return bytes allocated

Right now the ap_bytes_in_pool function returns the number of bytes used by
blocks in that pool, instead of the number of bytes which have been allocated
out of that particular pool. This makes it basically unusable for trying to see
where memory is being allocated into pools. For example, I ran into problems
when trying to investigate where mod_ssl was using memory and if it was leaking
into its own permanent_pool that survives reloads without being cleared.

This patch makes ap_bytes_in_pool return the number of bytes allocated out of
the pool. Of course, this is really the summation of the allocations after each
allocation is rounded up to a multiple of CLICK_SZ.

 - David Harris
   Principal Engineer, DRH Internet Services


diff -r -u3 apache_1.3.6_orig/src/main/alloc.c apache_1.3.6/src/main/alloc.c
--- apache_1.3.6_orig/src/main/alloc.c  Wed Aug  4 12:05:12 1999
+++ apache_1.3.6/src/main/alloc.c       Wed Aug  4 12:11:40 1999
@@ -355,6 +355,18 @@
     return size;
 }

+static long bytes_in_block_list_allocated(union block_hdr *blok)
+{
+    long size = 0;
+
+    while (blok) {
+       size += blok->h.first_avail - (char *) (blok + 1);
+       blok = blok->h.next;
+    }
+
+    return size;
+}
+

 /*****************************************************************
  *
@@ -521,7 +533,7 @@

 API_EXPORT(long) ap_bytes_in_pool(pool *p)
 {
-    return bytes_in_block_list(p->first);
+    return bytes_in_block_list_allocated(p->first);
 }
 API_EXPORT(long) ap_bytes_in_free_blocks(void)
 {



RE: [patch] make ap_bytes_in_pool return bytes allocated

Posted by David Harris <dh...@drh.net>.
Rodent of Unusual Size [Ken.Coar@Golux.Com] wrote:
> This is changing the behaviour of an existing function.  There may
> be portions of the code that depend upon the current behaviour,
> so this is out (for 1.3, at least).  A new function such as
> ap_pool_usage() that does this would probably be the better approach.

I've attached a new patch that does exactly this: it creates a new function
named ap_pool_usage() that returns the bytes allocated from the pool and
ap_bytes_in_pool() is left alone.

I just did a quick build, and I've verified that this patch works when applied
to apache_1.3.6.

 - David Harris
   Principal Engineer, DRH Internet Services



Re: [patch] make ap_bytes_in_pool return bytes allocated

Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
David Harris wrote:
> 
> Right now the ap_bytes_in_pool function returns the number of bytes
> used by blocks in that pool, instead of the number of bytes which have
> been allocated out of that particular pool. This makes it basically
> unusable for trying to see where memory is being allocated into pools.
> 
> This patch makes ap_bytes_in_pool return the number of bytes allocated
> out of the pool. Of course, this is really the summation of the
> allocations after each allocation is rounded up to a multiple of
> CLICK_SZ.

This is changing the behaviour of an existing function.  There may
be portions of the code that depend upon the current behaviour,
so this is out (for 1.3, at least).  A new function such as
ap_pool_usage() that does this would probably be the better approach.
-- 
#ken    P-)}

Ken Coar                    <http://Web.Golux.Com/coar/>
Apache Software Foundation  <http://www.apache.org/>
"Apache Server for Dummies" <http://ASFD.MeepZor.Com/>