Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many files can i have opened at once?

Tags:

c

io

disk

On a typical OS how many files can i have opened at once using standard C disc IO?

I tried to read some constant that should tell it, but on Windows XP 32 bit that was a measly 20 or something. It seemed to work fine with over 30 though, but i haven't tested it extensively.

I need about 400 files opened at once at max, so if most modern OS's support that, it would be awesome. It doesn't need to support XP but should support Linux, Win7 and recent versions of Windows server.

The alternative is to write my own mini file system which i want to avoid if possible.

like image 463
Michael Jefferson Avatar asked Mar 11 '10 13:03

Michael Jefferson


People also ask

How many files can windows open at once?

Quite convenient, doesn't it? But there is a limit Microsoft set in Windows to prevent you from opening hundreds of files all at once, which most likely will crash your computer if you do. The magic number is 15.

How many files can you open in C?

The C run-time libraries have a 512 limit for the number of files that can be open at any one time.

What is open file limit?

To check the maximum number of open files that can be opened in the current active session, Execute the following command: 1. cat /proc/sys/fs/file-max. Here, The maximum open file limit is set to 100000. The hard limit is 1048576 and soft limit is 1024.


1 Answers

On Linux, this is dependent on the amount of available file descriptors. You can use ulimit -n to set / show the number of available FD's per shell.

See these instructions to how to check (or change) the value of available total FD:s in Linux.

This IBM support article suggests that on Windows the number is 512, and you can change it in the registry (as instructed in the article)

As open() returns the fd as int - size of int limits also the upper limit. (irrelevant as INT_MAX is a lot)

like image 161
Kimvais Avatar answered Oct 19 '22 18:10

Kimvais