Sign in to follow this  

Unix/Windows: # of open file handles

Recommended Posts

nimrand    238
I've never heard of a way to query the maximum number of handles. But, I know the limit is very large, more than you should really need. Is there a particular reason you were wanting to do this?

Share this post

Link to post
Share on other sites
fearyourself    122
My debian kernel 2.6.8-2-386 can open 1022 files, didn't try under windows though but this is how I did it...

[source lang=c]
#include <stdio.h>

int main()
int cnt=0;
//just in case
printf("Max: %d\n",cnt);
return 1;


[Edit]: You can close the standard entry/output and standard error and then get 1025...

Share this post

Link to post
Share on other sites
Michalson    1657
Original post by ace_lovegrove
Hi bud,

I googled and found this. I couldn't see what kernel version it was talking about but i suppose it is a rough guide if nothing else.

Hope it helps,


I don't know much on the Linux side, so we'll assume that document is correct (Linux = 1024 file handles)

On the Windows side, NT based Windows (NT 4, 2000, XP) has 2048 handles.

Windows 9X I'm not sure of for one reason: Unlike Windows NT, which only runs DOS VMs when you run a DOS program, Windows 9X (95/98ME) had a number of legacy DOS elements for running things like real mode drivers and such. Under Windows, each DOS VM uses a number of file handles - IIRC the system itself needs to grab about 20 to run various parts of the DOS VM (since the program is not being given direct access to the hardware), and another 10 (or more depending on system settings) get reserved for the program itself. So basically each DOS VM process (including a bunch of thunking processes automatically run by the system) could be reserving 30 handles each, whether it uses them or not (to be honest I'm not sure how accurate I remember all this, as Windows 95/DOS issues are something I haven't had to think about for a very long time).

Share this post

Link to post
Share on other sites
Basiror    241
well I have implemented a .zip reader which serves as my personal packfile format in all future projects

and now i just implemented a filesystem

1. the filesystems searches for all zip files in modification folder then in the main folder
2. i build a file hierarchy on top of this
a) first archived files
b) files on harddisc

in the case of a) I could simply leave the archive files open until I am done with loading after this I close the file handles but keep the archive's central directory to allow further reading later on

I guess opening and closing 3000 filehandles takes a little bit longer than opening 10-100 archives

since each file opening call has to:
a) find the file in a file index/list(whatever partition you use)
b) seek to the file and buffer a few kbs to begin with reading

this basically eleminates the use of archives as packfiles

my debian installation supports 2048 open file handles, however its the 686 version

thx for ya help :)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this