How to control virtual memory management in linux?
- by chmike
I'm writing a program that uses an mmap file to hold a huge buffer organized as an array of 64 MB blocks.
The blocks are used to aggregate data received from different hosts through the network. As a consequence the total data size written in each block is not known in advance. Most of the time it is only 2MB but in some cases it can be up to 20MB or more.
The data doesn't stay long in the buffer. 90% is deleted after less than a second and the rest is transmitted to another host.
I would like to know if there is a way to tell the virtual memory manager that ram pages are not dirty anymore when data is deleted.
Should I use mmap and munmap when a block is used and released to control the virtual memory ? What would be the overhead of doing this ?
Also, some colleagues expressed concerns about the performance impact of allocating such a big mmap space. I expect it to behave like a swap file so that only dirty pages are to be considered.