How many Windows handles in use is “too many”?

前端 未结 5 1092
再見小時候
再見小時候 2021-02-03 10:49

I understand that the answer to this question may depend on registry settings and on the version of Windows, and perhaps on the amount of RAM if there is not enough memory. For

5条回答
  •  温柔的废话
    2021-02-03 11:26

    As per this recent blog post the limit of total handles for a process in Windows 10 is hard-coded as 16*1024*1024 or 16,777,216.

    As the Windows Executive (see also here) also stores some tracking information about handles, the actual limits are 16,711,680 for 64-bit Windows 10 and 16,744,448 for 32-bit Windows 10:

    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.

提交回复
热议问题