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.
CodePudding user response:
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:
$ cd
$ ls -Flha
After locating the .vscode
directory, inspect the files and directories with ls
command and any useful options/flags such as -R
(to list recursively). You can use pipes and filters technique including wc
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!
CodePudding user response:
You can increase the maximum file descriptors limit by ulimit
.
Type ulimit -n
for display you current file descriptors limit
For change limit type ulimit -n NEED_LIMIT
where NEED_LIMIT - number of maximum file descriptors
e.g. ulimit -n 4096