Date: Sun, 17 Aug 2008 15:39:39 -0700 From: Tait <freebsd@t41t.com> To: freebsd-questions@freebsd.org Subject: Re: Max. number of opened files, efficiency Message-ID: <20080817223939.GK20385@ece.pdx.edu>
next in thread | raw e-mail | index | archive | help
> How many files can I open under FreeBSD, at the same time? > ... > I tried to open 1000 temporary files and I could do so within one second. > > Another interesting (offtopic) question is that I could not open 10 000 > files under Windows XP. Error was "too many open file". How to overcome > this? The maximum number of files is controlled by kern.maxfilesperproc in /etc/sysctl.conf. It appears (on my 7.0 system) that the default is 2599. The maximum number of files per process for Windows XP is controlled in stdio.h and is set to 512 (with three eaten by stdin/stdout/stderr). On earlier versions of Windows, this number was much lower. The way to "overcome" this is almost always to redesign your program. You're not spawning 1000 threads (I hope) to write to every file simultaneously, so you can probably move the open/write/close-file inside your 1-to-1000 for loop and only need one file open at once, which is much more reasonable. If the size of your temporary files is small, you might look at using in-memory variables instead of files. Tait
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080817223939.GK20385>