How to load (or map) file part maximum size, but fit in RAM on Windows?

情到浓时终转凉″ 提交于 2020-07-23 06:20:42

问题


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/62825073/allocate-the-maximum-amount-of-memory-whout-paging-in-c-under-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!