使用 mmap 时如何限制内存中锁定的数据量?
在我的应用程序中,我映射一个非常大的文件并随机访问这些位置。然而,在一定次数的访问之后,内存被完全使用,程序开始崩溃。
我为每次访问尝试了 madvise(fd, range, MADV_RANDOM)
和 madvise(fd, range, MADV_DONT_NEED)
但这不起作用。我还尝试了 setrlimit.RLIMIT_MEMLOCK 来限制 RAM 中锁定的内存量。
In my application I mmap a very large file and access the locations randomly. However after a certain number of accesses the memory is completely used and the program starts to thrash.
I tried madvise(fd, range, MADV_RANDOM)
and madvise(fd, range, MADV_DONT_NEED)
for every access but this doesn't work. I also tried setrlimit.RLIMIT_MEMLOCK
to limit the amount of memory locked in RAM.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论