http://msdn.microsoft.com/en-us/library/6e3b887c(VS.80).aspx
is there a way to have more than 2048 open files at a time per application using _wopen.
32 or 64 bit OS – same limit!
By default, up to 512 files can be open simultaneously at the stream I/O level. This level includes files opened and accessed using the fopen , fgetc , and fputc family of functions. The limit of 512 open files at the stream I/O level can be increased to a maximum of 8,192 by use of the _setmaxstdio function.
No. By looking into the CRT source code, we can know the CRT limited the max number.
/*
* Make sure the request is reasonable.
*/
_VALIDATE_RETURN(((maxnum >= _IOB_ENTRIES) && (maxnum <= _NHANDLE_)), EINVAL, -1);
The NHANDLE:
#define _NHANDLE_ (IOINFO_ARRAYS * IOINFO_ARRAY_ELTS)
Those constants:
/*
* Definition of IOINFO_L2E, the log base 2 of the number of elements in each
* array of ioinfo structs.
*/
#define IOINFO_L2E 5
/*
* Definition of IOINFO_ARRAY_ELTS, the number of elements in ioinfo array
*/
#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
/*
* Definition of IOINFO_ARRAYS, maximum number of supported ioinfo arrays.
*/
#define IOINFO_ARRAYS 64
As you can see, it's limited by the implementation of the CRT.
No.
I believe the limit has to do with the ability to inherit the open files from a CreateProcess call. The CreateProcess has only 2048 slots for passing handles (both on 32-bit and 64-bit). You can debug a program and step into the system, exec, or spawn CRT functions to see the limit of the 2048 slots.
If you use the Win32 file API (CreateFile, WriteFile, ReadFile, CloseHandle, etc.), then you don't have a limit on open files (well, you do but I believe it is based on your resources like memory).
See Is there a limit on number of open files in Windows.
From the comments on the accepted answer it looks like there is no way to change this. Perhaps you can use the "CreateFile" api call in place of _wopen?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With