httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Harris" <dhar...@drh.net>
Subject [patch] make ap_bytes_in_pool return bytes allocated
Date Wed, 04 Aug 1999 16:17:31 GMT

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)
 {



Mime
View raw message