mmap and memory usage

后端 未结 3 552
别那么骄傲
别那么骄傲 2021-02-05 12:37

I am writing a program that receives huge amounts of data (in pieces of different sizes) from the network, processes them and writes them to memory. Since some pieces of data ca

3条回答
  •  梦谈多话
    2021-02-05 13:12

    I believe mmap doesn't require all data to be in memory at the same moment - it uses the page cache to keep recently used pages in memory, and the rest on disk.

    If you are reading one chunk at a time, using a temporary file probably won't help you, but if you are reading multiple chunks concurrently using multiple threads, processes, or using select/poll, then it might.

提交回复
热议问题