From: Arun Prakash Jana Date: Sun, 20 Aug 2017 19:25:45 +0000 (+0530) Subject: Limit max open fds to 20K. X-Git-Tag: v1.4~52 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=be77094235269c0c95f0459535c20ba68c8845bf;p=nnn.git Limit max open fds to 20K. --- diff --git a/nnn.c b/nnn.c index 4605d191..4199feea 100644 --- a/nnn.c +++ b/nnn.c @@ -246,10 +246,16 @@ max_openfds() rl.rlim_cur = rl.rlim_max; /* Return ~75% of max possible */ - if (setrlimit(RLIMIT_NOFILE, &rl) == 0) - return (rl.rlim_max - (rl.rlim_max >> 2)); + if (setrlimit(RLIMIT_NOFILE, &rl) == 0) { + limit = rl.rlim_max - (rl.rlim_max >> 2); + /* + * 20K is arbitrary> If the limit is set to max possible + * value, the memory usage increases to more than double. + */ + return limit > 20480 ? 20480 : limit; + } - return 32; + return limit; } /*