Hacker News new | ask | show | jobs
by nextaccountic 752 days ago
Can't mlock be wrapped out in a safe API?
1 comments

Probably, but I'm not aware of any Java library that provides that functionality.
If 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-lib...

https://github.com/java-native-access/jna