The following call to SetSystemFileCacheSize() fails, however it passes if replace “FILE_CACHE_MIN_HARD_ENABLE ” with 0.
What am I doing wrong?
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");
}
It turns out that dwMinimumFileCacheSize must be 64KB less than dwMaximumFileCacheSize, if FILE_CACHE_MIN_HARD_ENABLE is enabled.
Here is the fix: