views:

42

answers:

1

Hi,

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

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?

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

Thanks, Parik

+1  A: 

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.

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

Adrian Willenbücher