Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access File using FILE_FLAG_RANDOM_ACCESS with a limit on cache size

Tags:

c++

windows

I want to access a file uisng using FILE_FLAG_RANDOM_ACCESS. But when a large file is accessed via FILE_FLAG_RANDOM_ACCESS, huge memory consumption could result in bad system performance. Is there a way to put a limit on cache size for a specific file handle?

like image 425
Sravan Goud Avatar asked Oct 31 '22 21:10

Sravan Goud


1 Answers

Windows doesn't provide a way to set a maximum cache size, but this is relatively easy to implement on your own. Open the file with FILE_FLAG_NO_BUFFERING and implement your own cache with an LRU list to determine when to evict blocks. Note that starting with Windows Server 2016, FILE_FLAG_RANDOM_ACCESS is less aggressive about retaining data in the cache, so this is less of a concern. Microsoft still recommends avoiding this flag, however.

Further reading: Troubleshoot Cache and Memory Manager Performance Issues

like image 150
Peter Ruderman Avatar answered Nov 11 '22 07:11

Peter Ruderman