diff --git a/src/vramfs.cpp b/src/vramfs.cpp index 34cd736..54a2f2d 100644 --- a/src/vramfs.cpp +++ b/src/vramfs.cpp @@ -9,6 +9,7 @@ #include #include #include +#include // Internal dependencies #include "vramfs.hpp" @@ -529,6 +530,11 @@ int main(int argc, char* argv[]) { memory::set_device(atoi(argv[4])); } + // Lock process pages in memory to prevent them from being swapped + if (mlockall(MCL_CURRENT | MCL_FUTURE)) { + std::cerr << "failed to lock process pages in memory, vramfs may freeze if swapped" << std::endl; + } + // Check for OpenCL supported GPU and allocate memory if (!memory::is_available()) { std::cerr << "no opencl capable gpu found" << std::endl;