将java进程锁定或固定到内存中 [英] Lock or Pin java process into memory

查看:164
本文介绍了将java进程锁定或固定到内存中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将java进程锁定到内存中。

Is there a way to lock a java process into memory.

使用像mlock / mlockall这样的东西可以将进程的内存锁定到内存中,这样就不会将其换出。使用这种方法是否可以在调用java进程之前编写C包装器以将java进程锁定到内存中?如果是这样,包装器将如何调用java程序 - fork / clone / vfork / execl?

Using something like mlock/mlockall it is possible to lock the memory of a process into memory, so that it doesn't get swapped out. With this approach is it possible to write a C wrapper before invoking the java process to lock the java process into memory? If so, how would the wrapper invoke the java program - fork/clone/vfork/execl?

或者可能还有其他方法可以将java进程锁定到内存中?

Or maybe there is some other way to lock a java process into memory?

谢谢,
Parixit

Thanks, Parixit

推荐答案

你不喜欢你必须编写一个包装器,你可以使用JNI从你的Java程序中调用mlock / mlockall;您甚至不必编写/编译接口代码,JNI会为您完成。

You don't have to write a wrapper, you can call mlock/mlockall from your Java program using JNI; you don't even have to write/compile the interface code, JNI does it for you.

有关详细信息,请参阅 Java Native Interface:程序员指南和规范其维基百科条目

For further information, see Java Native Interface: Programmer's Guide and Specification or its Wikipedia entry.

这篇关于将java进程锁定或固定到内存中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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