I am trying to fix a bug in an ubuntu 20.04 program where it silently crashes once the maximum opened file descriptors (1024) is exceeded. I noticed that when running the program with visual code, ubuntu allows that number to be exceeded. This happens even if I run the program from visual code’s terminal.
My question is how does visual code bypass this limitation, as I am looking to replicate that in my own app.
2
Answers
Solution below, but N.B., please review https://stackoverflow.com/help/how-to-ask.
It appears your question has two parts: A) max opened file descriptors in Ubuntu, and B) how vs code executes your program ‘bypassing’ said limit. Though you did not mention your Ubuntu version nor provide a sample of the error viz your program, I have proposed a general solution:
For question A: This question is already answered here: https://askubuntu.com/questions/1049058/how-to-increase-max-open-files-limit-on-ubuntu-18-04#1049062.
For question B: By default, VS Code runs in hidden directory in your home directory,
~/.vscode
. To find out the bypass (I am not sure that is what is going on here though), open terminal, and do the following:After locating the
.vscode
directory, inspect the files and directories withls
command and any useful options/flags such as-R
(to list recursively). You can use pipes and filters technique includingwc
with appropriate options for files and/or sub-directories (which may have been hidden, except we used -a flag to listen the hidden ones earlier), and output your results to view as a plaintext file. Try repeating until you find the culprit.I recommend this quick guide for a refresher if you need help working with CLI.
Cheers!
You can increase the maximum file descriptors limit by
ulimit
.Type
ulimit -n
for display you current file descriptors limitFor change limit type
ulimit -n NEED_LIMIT
where NEED_LIMIT – number of maximum file descriptorse.g.
ulimit -n 4096