You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2014/12/15 07:13:32 UTC

svn commit: r1645572 - /subversion/trunk/subversion/libsvn_subr/cache_config.c

Author: stefan2
Date: Mon Dec 15 06:13:31 2014
New Revision: 1645572

URL: http://svn.apache.org/r1645572
Log:
Limit the membuffer cache size to half the available address space
typically available (1GB for 32 bit processes).  This prevents running
OOM if the user configured cache sizes too ambitious for their platform.

The code itself is a static, slightly conservative sanity check. It does
not guarantee that the respective platform can actually provide that
much memory nor does it account for platforms that allow for more (e.g.
32 bit app under x64 Windows).

* subversion/libsvn_subr/cache_config.c
  (initialize_cache): Limit the per-process cache size to half of what
                      SVN expects to be addressable.

Modified:
    subversion/trunk/subversion/libsvn_subr/cache_config.c

Modified: subversion/trunk/subversion/libsvn_subr/cache_config.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/cache_config.c?rev=1645572&r1=1645571&r2=1645572&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/cache_config.c (original)
+++ subversion/trunk/subversion/libsvn_subr/cache_config.c Mon Dec 15 06:13:31 2014
@@ -27,6 +27,7 @@
 #include "private/svn_cache.h"
 
 #include "svn_pools.h"
+#include "svn_sorts.h"
 
 /* The cache settings as a process-wide singleton.
  */
@@ -80,7 +81,13 @@ initialize_cache(void *baton, apr_pool_t
   svn_membuffer_t **cache_p = baton;
   svn_membuffer_t *cache = NULL;
 
-  apr_uint64_t cache_size = cache_settings.cache_size;
+  /* Limit the cache size to about half the available address space
+   * (typ. 1G under 32 bits).
+   */
+  apr_uint64_t cache_size = MIN(cache_settings.cache_size,
+                                (apr_uint64_t)SVN_MAX_OBJECT_SIZE / 2);
+
+  /* Create caches at all? */
   if (cache_size)
     {
       svn_error_t *err;