SetSystemFileCacheSize function

Limits the size of the working set for the file system cache.

Syntax

BOOL SetSystemFileCacheSize(
  SIZE_T MinimumFileCacheSize,
  SIZE_T MaximumFileCacheSize,
  DWORD  Flags
);

Parameters

MinimumFileCacheSize

The minimum size of the file cache, in bytes. The virtual memory manager attempts to keep at least this much memory resident in the system file cache.

To flush the cache, specify (SIZE_T) -1.

MaximumFileCacheSize

The maximum size of the file cache, in bytes. The virtual memory manager enforces this limit only if this call or a previous call to SetSystemFileCacheSize specifies FILE_CACHE_MAX_HARD_ENABLE.

To flush the cache, specify (SIZE_T) -1.

Flags

The flags that enable or disable the file cache limits. If this parameter is 0 (zero), the size limits retain the current setting, which is either disabled or enabled.

Value Meaning
FILE_CACHE_MAX_HARD_DISABLE
0x2
Disable the maximum size limit.

The FILE_CACHE_MAX_HARD_DISABLE and FILE_CACHE_MAX_HARD_ENABLE flags are mutually exclusive.

FILE_CACHE_MAX_HARD_ENABLE
0x1
Enable the maximum size limit.

The FILE_CACHE_MAX_HARD_DISABLE and FILE_CACHE_MAX_HARD_ENABLE flags are mutually exclusive.

FILE_CACHE_MIN_HARD_DISABLE
0x8
Disable the minimum size limit.

The FILE_CACHE_MIN_HARD_DISABLE and FILE_CACHE_MIN_HARD_ENABLE flags are mutually exclusive.

FILE_CACHE_MIN_HARD_ENABLE
0x4
Enable the minimum size limit.

The FILE_CACHE_MIN_HARD_DISABLE and FILE_CACHE_MIN_HARD_ENABLE flags are mutually exclusive.

Return Value

If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.

Remarks

The calling process must enable the SE_INCREASE_QUOTA_NAME privilege.

Setting the MaximumFileCacheSize parameter to a very low value can adversely affect system performance.

To compile an application that uses this function, define _WIN32_WINNT as 0x0502 or later. For more information, see Using the Windows Headers.

The FILE_CACHE_* constants will be defined in the Windows header files starting with the Windows SDK for Windows Server 2008. If you are using header files from an earlier version of the SDK, add the following definitions to your code.

#ifndef FILE_CACHE_FLAGS_DEFINED

#define FILE_CACHE_MAX_HARD_ENABLE      0x00000001
#define FILE_CACHE_MAX_HARD_DISABLE     0x00000002
#define FILE_CACHE_MIN_HARD_ENABLE      0x00000004
#define FILE_CACHE_MIN_HARD_DISABLE     0x00000008

#endif // FILE_CACHE_FLAGS_DEFINED

Requirements

   
Minimum supported client Windows Vista, Windows XP Professional x64 Edition [desktop apps only]
Minimum supported server Windows Server 2008, Windows Server 2003 with SP1 [desktop apps only]
Target Platform Windows
Header memoryapi.h (include Windows.h, Memoryapi.h)
Library Kernel32.lib
DLL Kernel32.dll

See Also

GetSystemFileCacheSize

Memory Management Functions