当你使用mlockall设置的ram时会发生什么? [英] What happens when you run out of ram with mlockall set?

查看:212
本文介绍了当你使用mlockall设置的ram时会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个C ++应用程序,需要大量的内存进行批处理运行。
(> 20gb)



我的一些客户正在运行内存限制,有时操作系统开始交换,总运行时间加倍或更差。 >

我读过我可以使用mlockall来防止进程被换出。当进程内存需求以这种方式接近或超过可用的物理内存时,会发生什么?



我想答案可能是操作系统特定的,请列出您的操作系统

解决方案

会发生什么是你所看到的 - 没有分配更多的内存,因为你的应用程序已经获得了所有物理内存在系统中,因为这些不能被交换出去,没有什么可以malloc做,但失败。这种行为在大多数现代操作系统中是相同的。



如果你想使用mlockall(你真的不应该),你最好确保系统具有所需的物理内存量,否则你会在痛苦的世界 - malloc也会失败的其他进程,以及这些可能会崩溃你的系统。


I am working on a C++ application that requires a large amounts of memory for a batch run. (> 20gb)

Some of my customers are running into memory limits where sometimes the OS starts swapping and the total run time doubles or worse.

I have read that I can use the mlockall to keep the process from being swapped out. What would happen when the process memory requirements approaches or exceeds the the available physical memory in this way?

I guess the answer might be OS specific so please list the OS in your answer.

解决方案

What would happen is exactly what you are seeing - failure to allocate more memory, since your application has acquired all the physical memory in the system and since these can not be swapped out, there is nothing for malloc to do but fail. This behaviour will be the same across most modern operating systems.

If you want to use mlockall (and you really shouldn't) you better make sure that the system has the required amount of physical memory or else you will be in a world of pain - malloc will fail for other processes as well and these might crash your system.

这篇关于当你使用mlockall设置的ram时会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆