File handle limit in msvcrt

Mon May 31 21:10:00 GMT 1999

>From msdc vc++ docs

The _setmaxstdio function changes the maximum value for the number of files which may be simultaneously open at the stdio level. 

C run-time I/O now supports many more open files on Win32 platforms than in previous versions. Up to 2,048 files may be open 
simultaneously at the lowio level (that is, opened and accessed by means of the _open, _read, _write, and so forth family of I/O functions). 
Up to 512 files may be open simultaneously at the stdio level (that is, opened and accessed by 
means of the fopen, fgetc, fputc, and so forth family of functions). The limit of 512 open files at the stdio level 
may be increased to a maximum of 2,048 by means of the _setmaxstdio function.

Since stdio level functions, such as fopen, are built on top of the lowio functions, the maximum of 2,048 is a hard upper limit 
for the number of simultaneously open files accessed through the C run-time library.

Note   This upper limit may be beyond what is supported by a particular Win32 platform and configuration.   

Stream I/O Routines

On Wed, 12 May 1999 10:11:15 -0400, you wrote:

>i just happened to find this piece of information regarding file handle
>limits in msvcrt.dll
>"The C run-time libraries have a preset limit for the number of files that
>can be open at any one time. The limit for applications that link with the
>single-thread static library (LIBC.LIB) is 64 file handles or 20 file
>streams. Applications that link with either the static or dynamic
>multithread library (LIBCMT.LIB or MSVCRT.LIB and MSVCRT.DLL), have a limit
>of 256 file handles or 40 file streams. Attempting to open more than the
>maximum number of file handles or file streams causes program failure."
>i know mingw uses the msvcrt.dll and hence should have the above limitation
>but what about cygwin which uses glibc? Just curious ... i dont think there
>is any operating system limitation may be some TLS issue from Microsoft or
>some other stuff like that..
>Nirmal Prasad R.

Want to unsubscribe from this list?
Send a message to

More information about the Cygwin mailing list