问题
There is big file. I need fast sort it. I going to process the file by part, that fit in RAM, to avoid/degrees using page file (next step: merge parts). How to use max RAM?
My solution: use WinApi file memory mapping, but I don't knew how to get part of file maximum size, but fit RAM (how to determine size)?
回答1:
You can VirtualLock the pages you want to process. It locks in physical memory the size you need (if there is enough) swapping others to the paging file.
You can use the GlobalMemoryStatusEx function to determine how much memory your application can allocate without severely impacting other applications.
So you could map the file and lock the pages you are going to process.
来源:https://stackoverflow.com/questions/62904480/how-to-load-or-map-file-part-maximum-size-but-fit-in-ram-on-windows