none
Windows中有没有关于“最大文件打开数”的限制? RRS feed

  • 问题

  • UNIXlinux系统里有个参数叫Nfile (最大文件打开数),因这个值会影响到ORACLE 数据库的运行,所以想请教一下在windows下有没有这样的概念?windows 最大能打开的文件数只依赖于内存容量还是有其他相应的定义?

    harry

    2013年5月13日 7:40

答案

  • NT下,per process 的 handle count limit应该 只有32位和64位之分,文章里写道了

    a handle entry is 8-bytes on 32-bit Windows and 12-bytes on 64-bit Windows.

    The Executive allocates handle tables on demand in page-sized blocks that it divides into handle table entries. That means a page, which is 4096 bytes on both x86 and x64, can store 512 entries on 32-bit Windows and 256 entries on 64-bit Windows. The Executive determines the maximum number of pages to allocate for handle entries by dividing the hard-coded maximum,16,777,216, by the number of handle entries in a page, which results on 32-bit Windows to 32,768 and on 64-bit Windows to 65,536. Because the Executive uses the first entry of each page for its own tracking information, the number of handles available to a process is actually 16,777,216 minus those numbers, which explains the results obtained by Testlimit: 16,777,216-65,536 is 16,711,680 and 16,777,216-65,536-32,768 is 16,744,448.

    但是,你要知道,这只是Handle的hardcoded Max count,实际你可能更本触及不到这个Limit,因为一般不会去创建(也由于内存限制,创建不出)这么多Kernel Object,也不会像TestLimit程序那样疯狂地DuplicateHandle去指向同一个Kernel Object。。。。。

    ------------------------------------------------------------------------------------------------------------

    说到这里,貌似还需要补充另一半概念。

    因为你问的“最大文件打开数”,我一开始把你指引到handle limit,是让你知道在一条河边钓鱼,最大可以有多少鱼竿(比作handle)同时钓,而没有说河里最多可以容纳多少条鱼(比作File Object)。。。

    那么,河里可以有多少条鱼(File Object),你又得参见Mark Russinovich 的另一篇博文,得知道你能有多大的Non-Paged Pool

    Pushing the Limits of Windows: Paged and Nonpaged Pool
    http://blogs.technet.com/b/markrussinovich/archive/2009/03/26/3211216.aspx

    Nonpaged pool is therefore always kept present in physical memory and nonpaged pool virtual memory is assigned physical memory. Common system data structures stored in nonpaged pool include the kernel and objects that represent processes and threads, synchronization objects like mutexes, semaphores and events, references to files, which are represented as file objects, and I/O request packets (IRPs), which represent I/O operations.

     

    2013年5月17日 8:05

全部回复

  • Windows下,对于打开文件,是以一个Kernel Object去标识的,并且User Mode程序通过一些WinAPI(传入这个Object的Handle)来得以访问它。

    然后Windows下对于Handle是有Limit的,详见 Mark Russinovich 的博文

    Pushing the Limits of Windows: Handles
    http://blogs.technet.com/b/markrussinovich/archive/2009/09/29/3283844.aspx

    2013年5月14日 1:34
  • 在这个文档中,看不到各个版本的Windows 的Handle的Limit呀。能否再具体一点,谢谢!

    harry

    2013年5月16日 0:17
  • NT下,per process 的 handle count limit应该 只有32位和64位之分,文章里写道了

    a handle entry is 8-bytes on 32-bit Windows and 12-bytes on 64-bit Windows.

    The Executive allocates handle tables on demand in page-sized blocks that it divides into handle table entries. That means a page, which is 4096 bytes on both x86 and x64, can store 512 entries on 32-bit Windows and 256 entries on 64-bit Windows. The Executive determines the maximum number of pages to allocate for handle entries by dividing the hard-coded maximum,16,777,216, by the number of handle entries in a page, which results on 32-bit Windows to 32,768 and on 64-bit Windows to 65,536. Because the Executive uses the first entry of each page for its own tracking information, the number of handles available to a process is actually 16,777,216 minus those numbers, which explains the results obtained by Testlimit: 16,777,216-65,536 is 16,711,680 and 16,777,216-65,536-32,768 is 16,744,448.

    但是,你要知道,这只是Handle的hardcoded Max count,实际你可能更本触及不到这个Limit,因为一般不会去创建(也由于内存限制,创建不出)这么多Kernel Object,也不会像TestLimit程序那样疯狂地DuplicateHandle去指向同一个Kernel Object。。。。。

    ------------------------------------------------------------------------------------------------------------

    说到这里,貌似还需要补充另一半概念。

    因为你问的“最大文件打开数”,我一开始把你指引到handle limit,是让你知道在一条河边钓鱼,最大可以有多少鱼竿(比作handle)同时钓,而没有说河里最多可以容纳多少条鱼(比作File Object)。。。

    那么,河里可以有多少条鱼(File Object),你又得参见Mark Russinovich 的另一篇博文,得知道你能有多大的Non-Paged Pool

    Pushing the Limits of Windows: Paged and Nonpaged Pool
    http://blogs.technet.com/b/markrussinovich/archive/2009/03/26/3211216.aspx

    Nonpaged pool is therefore always kept present in physical memory and nonpaged pool virtual memory is assigned physical memory. Common system data structures stored in nonpaged pool include the kernel and objects that represent processes and threads, synchronization objects like mutexes, semaphores and events, references to files, which are represented as file objects, and I/O request packets (IRPs), which represent I/O operations.

     

    2013年5月17日 8:05