From: Jim Meyering Date: Sun, 15 Apr 2001 05:58:33 +0000 (+0000) Subject: (default_sort_size): Leave a 1/16 margin for RSS. X-Git-Tag: FILEUTILS-4_0_44~19 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=4b9aaf267e97db735549db1bafe130bde879586a;p=thirdparty%2Fcoreutils.git (default_sort_size): Leave a 1/16 margin for RSS. --- diff --git a/src/sort.c b/src/sort.c index 7f78765379..ecfa8287f0 100644 --- a/src/sort.c +++ b/src/sort.c @@ -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. */