Memory usage when using boost::iostreams::mapped_file

前端 未结 1 919
无人及你
无人及你 2020-12-12 00:39

I am pasting some code here which uses boost iostream to mmap & then writes to the mapped file:

typedef unordered_map work;

    int m         


        
相关标签:
1条回答
  • 2020-12-12 01:24
    1. VIRT will increase immediately (all pages are mapped into the process address space). RES will increase whenever pages are used, which causes them to be paged into the physical memory.

      This happens for as long as there is sufficient memory available, after which the OS starts purging LRU pages from the reserved sets (unless they were VirtualLock/mlock-ed or are otherwise unmovable (like kernel pages, DMA buffers, security sensitive data etc.).

      So, the OS optimistically leaves the pages reserved as long as possible (which improves performance as long as no other processes contend for the memory).

    2. This signifies that the OS is doing it's job.

    3. You're writing to disk. Disk access is (a lot) slower than memory access. How often the data actually gets written out to disk depends on tuning. This answer lists some of the tuning parameters that are available on linux (which you seem to be using):

      • Excessive synchronizing of memory mapped file in Apache module
    0 讨论(0)
提交回复
热议问题