mmap fails when length is larger than 4GB

后端 未结 5 1785
攒了一身酷
攒了一身酷 2020-12-05 11:41

(The correct code is in \'Update 5\')

I tried to map a range of memory from 0x100000000 to 0x200000000 in this example C code:

#include 

        
5条回答
  •  自闭症患者
    2020-12-05 12:20

    If you do not actually have significantly more than 8G of swap configured, then that large mapping is likely to fail.

    You can add the MAP_NORESERVE flag to mmap() to tell it not to reserve any swap space for the mapping up front.

提交回复
热议问题