0

以下对 SetSystemFileCacheSize() 的调用失败,但是如果将“FILE_CACHE_MIN_HARD_ENABLE”替换为 0,则会通过。

我究竟做错了什么?

SIZE_T dwMinimumFileCacheSize = 1048576; // Exact number reported by SetSystemFileCacheSize.
SIZE_T dwMaximumFileCacheSize = 1099511627776; // Exact number reported by SetSystemFileCacheSize.

int result = SetSystemFileCacheSize(
    dwMinimumFileCacheSize, // dwMinimumWorkingSetSize
    dwMaximumFileCacheSize,  // dwMaximumWorkingSetSize,
    FILE_CACHE_MIN_HARD_ENABLE // Works if this flag is set to 0.
  );
if (result == 0)
{
  // Error is "5" if it fails.
  wprintf(L"  Error E2469: Could not set size of system cache, error %u.\n", GetLastError());
}
else
{
  wprintf(L"  Pass.\n");
}
4

1 回答 1

0

事实证明,如果启用了 FILE_CACHE_MIN_HARD_ENABLE,dwMinimumFileCacheSize 必须比 dwMaximumFileCacheSize 小 64KB。

这是修复:

int result = SetSystemFileCacheSize(
    dwMinimumFileCacheSize - 64 * 1024, // dwMinimumWorkingSetSize
    dwMaximumFileCacheSize,  // dwMaximumWorkingSetSize,
    FILE_CACHE_MIN_HARD_ENABLE // Works if this flag is set to 0.
  );
于 2012-09-21T11:33:28.517 回答