如何防止一个程序/进程的分页? [英] How to prevent paging for one program / process?

查看:116
本文介绍了如何防止一个程序/进程的分页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要很多内存的程序,比如所有物理RAM的2/3。在一些运行后,我的操作系统开始将程序交换到hdd。但是我需要程序响应非常快,所以我需要防止分页的进程。



如何防止操作系统交换一个进程? / p>

感谢您的帮助!

解决方案

,call:

  mlockall(MCL_CURRENT | MCL_FUTURE); 

(如果你没有程序的源代码,你必须取消 ptrace 可以这样做)。



请注意,这将增加进程失败的内存分配机会。


I have a program that requires much memory, like 2/3 of all the physical ram. After some runtime my operating system begins to swap the program to hdd. But I need the program to respond very fast all the time, so I need to prevent paging for that process.

How can you prevent the OS to swap one process?

Thanks for any help!

解决方案

At the start of the program, call:

mlockall(MCL_CURRENT | MCL_FUTURE);

(If you do not have the source to the program, you'll have to debauch the process with ptrace to do this).

Be aware that this will increase the chances of memory allocations made by the process failing.

这篇关于如何防止一个程序/进程的分页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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