]> granicus.if.org Git - apache/commitdiff
Add a new directive: MaxMemFree. MaxMemFree makes it possible
authorSander Striker <striker@apache.org>
Thu, 4 Jul 2002 15:20:54 +0000 (15:20 +0000)
committerSander Striker <striker@apache.org>
Thu, 4 Jul 2002 15:20:54 +0000 (15:20 +0000)
to configure the maximum amount of memory the allocators will
hold on to for reuse.  Anything over the MaxMemFree threshold
will be free()d.  This directive is usefull when uncommon large
peaks occur in memory usage.  It should _not_ be used to mask
defective modules' memory use.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95954 13f79535-47bb-0310-9956-ffa450edef68

15 files changed:
CHANGES
server/core.c
server/mpm/beos/beos.c
server/mpm/beos/mpm.h
server/mpm/experimental/leader/leader.c
server/mpm/experimental/leader/mpm.h
server/mpm/experimental/threadpool/mpm.h
server/mpm/experimental/threadpool/threadpool.c
server/mpm/netware/mpm.h
server/mpm/netware/mpm_netware.c
server/mpm/prefork/mpm.h
server/mpm/prefork/prefork.c
server/mpm/worker/mpm.h
server/mpm/worker/worker.c
server/mpm_common.c

diff --git a/CHANGES b/CHANGES
index bbd634304c894d9d85afdb1445789cef516141df..4248b56dc4026adcada01226b4ac5145a182ca03 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,10 @@
 Changes with Apache 2.0.40
+  *) Add a new directive: MaxMemFree.  MaxMemFree makes it possible
+     to configure the maximum amount of memory the allocators will
+     hold on to for reuse.  Anything over the MaxMemFree threshold
+     will be free()d.  This directive is usefull when uncommon large
+     peaks occur in memory usage.  It should _not_ be used to mask
+     defective modules' memory use.  [Sander Striker]
 
   *) Fixed the Content-Length filter so that HTTP/1.0 requests to CGI
      scripts would not result in a truncated response.
index c2f23aeb5a32033aa7c54f99da606441546fb25b..c223220246bf2ef3a83148b84db9da60263b47da 100644 (file)
@@ -3043,6 +3043,10 @@ AP_INIT_TAKE1("CoreDumpDirectory", ap_mpm_set_coredumpdir, NULL, RSRC_CONF, \
 AP_INIT_TAKE1("AcceptMutex", ap_mpm_set_accept_lock_mech, NULL, RSRC_CONF, \
               ap_valid_accept_mutex_string),
 #endif
+#ifdef AP_MPM_WANT_SET_MAX_MEM_FREE
+AP_INIT_TAKE1("MaxMemFree", ap_mpm_set_max_mem_free, NULL, RSRC_CONF,\
+              "Maximum number of 1k blocks a particular childs allocator may hold."),
+#endif
 { NULL }
 };
 
index bf4807ebb65a4e5ad7085fc289e76cc4a0a17588..3aaa1e3859dbd4c723561b9634fa3d2485af1a2b 100644 (file)
@@ -383,6 +383,7 @@ static int32 worker_thread(void * dummy)
     sigprocmask(SIG_BLOCK, &sig_mask, NULL);
 
     apr_allocator_create(&allocator);
+    apr_allocator_max_free_set(allocator, ap_max_mem_free);
     apr_pool_create_ex(&ptrans, tpool, NULL, allocator);
     apr_allocator_owner_set(allocator, ptrans);
 
index 37f1b22055cda7a2d75a2e6c5a766731c7c8fe17..cb84cf3f277fdf789b0c181928a49142387d6e58 100644 (file)
@@ -73,6 +73,7 @@
 #define AP_MPM_WANT_SET_SCOREBOARD
 #define AP_MPM_WANT_SET_MAX_REQUESTS
 #define AP_MPM_WANT_SET_COREDUMPDIR
+#define AP_MPM_WANT_SET_MAX_MEM_FREE
 
 extern int ap_max_child_assigned;
 extern server_rec *ap_server_conf;
index 661b0fce667c77530e077e6d36c346ad492b1608..02d55a1204ca3e808f256f7af32eef6a72d83576 100644 (file)
@@ -821,6 +821,7 @@ static void *worker_thread(apr_thread_t *thd, void * dummy)
     free(ti);
 
     apr_allocator_create(&allocator);
+    apr_allocator_max_free_set(allocator, ap_max_mem_free);
     apr_pool_create_ex(&ptrans, NULL, NULL, allocator);
     apr_allocator_owner_set(allocator, ptrans);
     bucket_alloc = apr_bucket_alloc_create(tpool);
index 5e7afa8fde84bb091f96758da8a9c1a3fc2e9d62..6214e4509daa5af246029b8d61f6cb21fdaddbfe 100644 (file)
@@ -74,6 +74,7 @@
 #define AP_MPM_WANT_SET_MAX_REQUESTS
 #define AP_MPM_WANT_SET_COREDUMPDIR
 #define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
+#define AP_MPM_WANT_SET_MAX_MEM_FREE
 #define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
 
 #define AP_MPM_USES_POD 1
index f94288d90ab52cb4fc62bae930bc53a1ad13181d..68adde9b176debe69ffbc56530d25ed2689f3df7 100644 (file)
@@ -75,6 +75,7 @@
 #define AP_MPM_WANT_SET_COREDUMPDIR
 #define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
 #define AP_MPM_WANT_SIGNAL_SERVER
+#define AP_MPM_WANT_SET_MAX_MEM_FREE
 #define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
 
 #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
index dffd4634f9a2469c0edccafb397b147d3f67d2cc..79e18ec41425eeb3258ea14f88ac9bee52c94893 100644 (file)
@@ -1045,6 +1045,7 @@ static void * APR_THREAD_FUNC worker_thread(apr_thread_t *thd, void * dummy)
     ap_update_child_status_from_indexes(process_slot, thread_slot, SERVER_STARTING, NULL);
 
     apr_allocator_create(&allocator);
+    apr_allocator_max_free_set(allocator, ap_max_mem_free);
     apr_pool_create_ex(&ptrans, NULL, NULL, allocator);
     apr_allocator_owner_set(allocator, ptrans);
 
index 74a5f55194bf44f4fa7af782daaf9adb791d16d8..f53125944b842ba2e71a86215d303f44a12f486b 100644 (file)
@@ -72,6 +72,7 @@
   #define AP_MPM_WANT_SET_LOCKFILE 
 */
 #define AP_MPM_WANT_SET_MAX_REQUESTS
+#define AP_MPM_WANT_SET_MAX_MEM_FREE
 #define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
 /*#define AP_MPM_WANT_SET_COREDUMPDIR
   #define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH 
index 621d470963eaa30b46c5c484e4dd8dfd3dfee510..59abe9651721b197c919d58964a5b7e5fee06782 100644 (file)
@@ -373,6 +373,7 @@ void worker_main(void *arg)
     tv.tv_usec = 0;
 
     apr_allocator_create(&allocator);
+    apr_allocator_max_free_set(allocator, ap_max_mem_free);
     apr_pool_create_ex(&ptrans, NULL, NULL, allocator);
     apr_allocator_owner_set(allocator, ptrans);
     apr_pool_tag(ptrans, "transaction");
index fc2ff771c5125a4796ba9eddde02ad58151a1ff0..0c14b0c8e5795b06eb27246001444d72c9555447 100644 (file)
@@ -78,6 +78,7 @@
 #define AP_MPM_WANT_SET_COREDUMPDIR
 #define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
 #define AP_MPM_WANT_SIGNAL_SERVER
+#define AP_MPM_WANT_SET_MAX_MEM_FREE
 #define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
 
 #define AP_MPM_USES_POD 1
index 3d13b13638cf6042e781ecad20a6d902e362acb5..ec12fd8376807f67a33510df154a9cc7fb5251ba 100644 (file)
@@ -558,6 +558,7 @@ static void child_main(int child_num_arg)
      * we can have cleanups occur when the child exits.
      */
     apr_allocator_create(&allocator);
+    apr_allocator_max_free_set(allocator, ap_max_mem_free);
     apr_pool_create_ex(&pchild, pconf, NULL, allocator);
     apr_allocator_owner_set(allocator, pchild);
 
index a22c8f0686eed50bc9d792f999318dd55abcbad1..1c34a10feb2b4af96a45c9c0f80ca36c567cfe66 100644 (file)
@@ -75,6 +75,7 @@
 #define AP_MPM_WANT_SET_COREDUMPDIR
 #define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
 #define AP_MPM_WANT_SIGNAL_SERVER
+#define AP_MPM_WANT_SET_MAX_MEM_FREE
 #define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
 
 #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
index 9882091551277a415151bbd46007185fd501b359..8d8575db7bb8b2e1f4fac1e9727ce3975b63e520 100644 (file)
@@ -796,6 +796,7 @@ static void *listener_thread(apr_thread_t *thd, void * dummy)
                 apr_allocator_t *allocator;
 
                 apr_allocator_create(&allocator);
+                apr_allocator_max_free_set(allocator, ap_max_mem_free);
                 apr_pool_create_ex(&ptrans, NULL, NULL, allocator);
                 apr_allocator_owner_set(allocator, ptrans);
             }
index 98f482dd63c129f8e2fa8286d1b4f06a082ed172..ec6485da644051823dbb253eeb585bdc99ea2052 100644 (file)
@@ -880,3 +880,26 @@ void ap_mpm_rewrite_args(process_rec *process)
 
 #endif /* AP_MPM_WANT_SIGNAL_SERVER */
 
+#ifdef AP_MPM_WANT_SET_MAX_MEM_FREE
+apr_uint32_t ap_max_mem_free = 0;
+
+const char *ap_mpm_set_max_mem_free(cmd_parms *cmd, void *dummy,
+                                   const char *arg)
+{
+    long value;
+    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+    if (err != NULL) {
+        return err;
+    }
+    
+    value = strtol(arg, NULL, 0);
+    if (value < 0 || errno == ERANGE)
+        return apr_pstrcat(cmd->pool, "Invalid MaxMemFree value: ", 
+                           arg, NULL);
+
+    ap_max_mem_free = (apr_uint32_t)value * 1024;
+
+    return NULL;
+}
+
+#endif /* AP_MPM_WANT_SET_MAX_MEM_FREE */