02-16-2022 06:21 AM
What is the limit on the number of open files on a cRIO? There was a question that came up as to how many files could be opened and not closed by the Close File VI. I know that failing to close a file when the reference is no longer needed is a memory leak that will eventually cause the cRIO to stop execution of the code, but is there a limit to the number of open files?
Solved! Go to Solution.
02-16-2022 01:23 PM - edited 02-16-2022 01:24 PM
@David_Fanelli wrote:
What is the limit on the number of open files on a cRIO? There was a question that came up as to how many files could be opened and not closed by the Close File VI. I know that failing to close a file when the reference is no longer needed is a memory leak that will eventually cause the cRIO to stop execution of the code, but is there a limit to the number of open files?
I would ask whoever had that question the better question: "Why do you need to know?" I feel like any architecture where you will have to worry about exceeding the number of open files allowed in an OS might need to be re-thought.
02-16-2022 01:58 PM
I asked out of curiosity more than anything else. My hypothetical case was where a logger resident in a cRIO failed to close the log file in use before opening a new one using the same file reference. Would the resulting memory leak case resource starvation and system shutdown, or would the limiting factor be number of open files?
02-16-2022 03:25 PM
@David_Fanelli wrote:
I asked out of curiosity more than anything else. My hypothetical case was where a logger resident in a cRIO failed to close the log file in use before opening a new one using the same file reference. Would the resulting memory leak case resource starvation and system shutdown, or would the limiting factor be number of open files?
Hmmm, interesting thought experiment. I don't really know the answer to that, and if anyone actually know, please feel free to let us know! As for the practical side of things, try make sure that the log file closes "no matter what". I put it in quotes because you can't ever guarantee that it will close given unforeseen disaster, but you can get pretty close to that, so that almost the only case where it would stay open is a case where you would have to do a reboot - which i suppose is going to close that file anyway.
02-16-2022 05:38 PM - edited 02-16-2022 05:39 PM
As NI Linux RT is simply a Linux system for pretty much anything that you may be concerned about, that is 1024 per process and something like 70000 in total.
The max number per process can be changed by an admin with ulimit -n and the max number of total file handles is in /proc/sys/fs/file-max.
02-16-2022 05:40 PM
@rolfk wrote:
Normally that is 1024 per process and something like 70000 in total.
The max number per process can be changed by an admin with ulimit -n and the max number of total file handles is in /proc/sys/fs/file-max.
Nice. I knew someone would know, and somehow I knew it would be you, rolfk. 🙂
Thanks!