]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(default_sort_size): Leave a 1/16 margin for RSS.
authorJim Meyering <jim@meyering.net>
Sun, 15 Apr 2001 05:58:33 +0000 (05:58 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 15 Apr 2001 05:58:33 +0000 (05:58 +0000)
src/sort.c

index 7f7876537911b8e1a0cfedd55f841abb1b4dd49d..ecfa8287f09c0a6986773cc42e4e21fa6a288802 100644 (file)
@@ -672,8 +672,10 @@ default_sort_size (void)
   size /= 2;
 
 #ifdef RLIMIT_RSS
-  if (getrlimit (RLIMIT_RSS, &rlimit) == 0 && rlimit.rlim_cur < size)
-    size = rlimit.rlim_cur;
+  /* Leave a 1/16 margin for RSS to leave room for code, stack, etc.
+     Exceeding RSS is not fatal, but can be quite slow.  */
+  if (getrlimit (RLIMIT_RSS, &rlimit) == 0 && rlimit.rlim_cur / 16 * 15 < size)
+    size = rlimit.rlim_cur / 16 * 15;
 #endif
 
   /* Use no less than the minimum.  */