I have been using freebsd for few days. But everytime after few hours it is stuck with error
“too many open files” and I can’t even run sudo.
I tried to fix limits by known methods for FreeBSD but doesn’t help.
Here when it happened again:
nomad@NomadBSD ~> ulimit -a
Maximum size of core files created (kB, -c) unlimited
Maximum size of a process’s data segment (kB, -d) 33554432
Maximum size of files created by the shell (kB, -f) unlimited
Maximum size that may be locked into memory (kB, -l) 64
Maximum resident set size (kB, -m) unlimited
Maximum number of open file descriptors (-n) 20000000
Maximum stack size (kB, -s) 524288
Maximum amount of cpu time in seconds (seconds, -t) unlimited
Maximum number of processes available to a single user (-u) 34218
Maximum amount of virtual memory available to the shell (kB, -v) unlimited
That’s odd. I would say, increase kern.maxfiles, but it is already insanely high, and kern.openfiles is only at ~ .3%. Could you please run the following script for a while (until you get that error again), and post the result here?
#!/usr/local/bin/perl
foreach (`fstat`) {
next if ($lc++ == 0);
$app = $2 if (/(\S+)\s+(\S+).*/);
$prev_counts{$app}++;
}
while (1) {
$lc = 0;
system("clear");
foreach (`fstat`) {
next if ($lc++ == 0);
$app = $2 if (/(\S+)\s+(\S+).*/);
$counts{$app}++;
}
printf("%-25s\tOPEN\tINCREASE\n", "PROCESS");
foreach $k (sort (keys %counts)) {
if ($prev_counts{$k} > 0) {
$incr{$k} += $counts{$k} - $prev_counts{$k};
}
printf("%-25s\t%d\t%d\n", $k, $counts{$k}, $incr{$k});
}
%prev_counts = %counts;
%counts = ();
sleep(5);
}
normally I just doing something in browser after time it happens.
With script running. I tried to open many applications. It didn’t happen then I watched youtube for a while and it happened. Here is the output at that time:
Yeah right now I have 32Gb, it is home PC. I don’t plan to use only here though.
I need it for my work I often have to change PCs, laptops… sometime very old PC.
Try to change unionfs’ max_files value from 32768 to 65536 in /etc/rc.d/mount_uzip. It seems, unionfs is responsible. The number of opened files does not decrease albeit programs are closed. I need to investigate further.
So I worked all day and it happened only in the evening…
at least I can work now.
nomad@NomadBSD ~> sysctl kern.openfiles
kern.openfiles: 68641
nomad@NomadBSD ~> sudo
Failed to execute process '/usr/local/bin/sudo'. Reason:
exec: Too many open files
this should be enough.
Because to get to that limit I used 3 chrome with different users, with 20 tabs on each.
Modeling in blender. at the same time compiling stm32 in keil that run in wine.
and many more heavy apps I could possibly find.
and it worked from 6am to midnight.
in real work I hardly get to that kind of usage …