I have a process that uses a lot of memory mapped files.
Problem is that those files are kept in physical memory, even when the machine is low on memory, and other processes require this memory.
I've tried using SetProcessWorkingSetSize to limit the process working set, but it doesn't help, the process' working set keeps growing over the max value.
Is there a better way to limit the process' working set?
Can I change Windows' heuristcs for paging memory mapped files?
Memory-mapped files are accessed through the operating system's memory manager, so the file is automatically partitioned into a number of pages and accessed as needed. You do not have to handle the memory management yourself.
In computer science, a memory map is a structure of data (which usually resides in memory itself) that indicates how memory is laid out. The term "memory map" can have different meanings in different contexts. It is the fastest and most flexible cache organization that uses an associative memory.
Memory-mapping is a mechanism that maps a portion of a file, or an entire file, on disk to a range of addresses within an application's address space. The application can then access files on disk in the same way it accesses dynamic memory.
File mapping is the process of mapping the disk sectors of a file into the virtual memory space of a process. Once mapped, your app accesses the file as if it were entirely resident in memory.
Ended up using brute force VirtualUnlock.
PROCESS_MEMORY_COUNTERS pmc;
if (GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc)) )
{
if (pmc.WorkingSetSize > MaxWorkingSetSize)
{
VirtualUnlock(FilePtr.pData, MaxWorkingSetSize);
UnmapViewOfFile(FilePtr.pData);
CloseHandle(FilePtr.hFileMap);
CloseHandle(FilePtr.hFile);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With