3 ms·
As a workaround, you can mlock your process which should prevent the application pages from being evicted by swap.
by dekhn 2y ago
As a workaround, you can mlock your process which should prevent the application pages from being evicted by swap.
- jbellis 2y agoFWIW this is what Cassandra does on startup, but it didn't seem worth it to go to the trouble of dealing with Unsafe for a demo project.
- nextaccountic 2y agoCan't mlock be wrapped out in a safe API?
- jbellis 2y agoProbably, but I'm not aware of any Java library that provides that functionality.
- papercrane 2y agoIf you don't mind using a preview feature you should be able to use the foreign function API to call mlockall without any unsafe code. Otherwise, JNA is probably the easiest way, and how Cassandra does it. https://docs.oracle.com/en/java/javase/21/core/calling-c-library-function-foreign-function-and-memory-api.html https://docs.oracle.com/en/java/javase/21/core/calling-c-lib... https://github.com/java-native-access/jna https://github.com/java-native-access/jna