Unix/Windows: # of open file handles

Started by
4 comments, last by Basiror 18 years, 4 months ago
Hi do you know if there s a way to query the maximum number and the number if currently open file handles? thx in advance
http://www.8ung.at/basiror/theironcross.html
Advertisement
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?
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,

ace
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;        FILE*f;        do        {                cnt++;                //just in case                if(cnt>100000)                        break;                f=fopen("main.c","w");        }while(f);        printf("Max: %d\n",cnt);        return 1;}


Jc

[Edit]: You can close the standard entry/output and standard error and then get 1025...
Quote: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,

ace


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).
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 :)
http://www.8ung.at/basiror/theironcross.html

This topic is closed to new replies.

Advertisement