当前位置:   article > 正文

(转)windows下fopen遇到文件限制的解决方法_c fopen too many open files

c fopen too many open files

转自:http://blog.csdn.net/joyyoj/article/details/5447150


昨天遇到一个问题:打开shp文件到85个时,发现再添加shp就会报错。我一开始怀疑是缓存写的有问题,后来跟踪了下,才发现问题居然在fopen,又测试下一把fopen,如果fopen读取txt,发现在读取第510个文件时就会失败。于是怀疑是文件打开数目有限制,搜索了一把,更改config.NT重启计算机还是不行。最后是使用_setmaxstdio提高了上限。

MSDN里的描述如下:

C run-time I/O now supports many more open files on Win32 platforms than in previous versions. Up to 2,048 files can 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 can be open simultaneously at the stdio level (that is, opened and accessed by means of the fopenfgetcfputc, and so forth family of functions). The limit of 512 open files at the stdio level can be increased to a maximum of 2,048 by means of the _setmaxstdio function.

Because 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.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/182971?site
推荐阅读
相关标签
  

闽ICP备14008679号