summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-04-15 05:58:33 +0000
committerJim Meyering <jim@meyering.net>2001-04-15 05:58:33 +0000
commit4b9aaf267e97db735549db1bafe130bde879586a (patch)
tree531315f24d8f07d080d7f1c9b56db274e7e21259 /src
parent9d3cbe12bd2d8e6dc595021df4cebd05649d97a2 (diff)
downloadcoreutils-4b9aaf267e97db735549db1bafe130bde879586a.tar.xz
(default_sort_size): Leave a 1/16 margin for RSS.
Diffstat (limited to 'src')
-rw-r--r--src/sort.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/sort.c b/src/sort.c
index 7f7876537..ecfa8287f 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. */