Sys::Mlockall - Prevent this process's memory from being placed in swap.
use Sys::Mlockall qw(:all);
if(mlockall(MCL_CURRENT | MCL_FUTURE) != 0) { die "Failed to lock RAM: $!"; }
[memory will not be swapped from here on out]
This module provides a quick-and-dirty interface to the mlockall() and munlockall() system calls. mlockall() can be used to prevent your process's memory from being placed in swap, which can be useful for scripts that deal with sensitive information (passwords / RSA keys / stardrive plans / etc).
Please see mlockall(2) for documentation on these. Their calling convention and return value are exactly the same, and errno will, by perl convention, be stored in $!.
errno
$!
By default, linux systems have the resource limit RLIMIT_MAXLOCK set to 64kb, which is insufficient for running perl scripts. The unit tests require root permissions to boost that limit to 32MB; in production, you may want to use the "ulimit" commanad, or add a rule to /etc/security/limits.conf (or /etc/security/limits.d/ if supported).
You may use this module under the same terms as perl itself.
Tyler MacDonald <japh@crackerjack.net>
To install Sys::Mlockall, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sys::Mlockall
CPAN shell
perl -MCPAN -e shell install Sys::Mlockall
For more information on module installation, please visit the detailed CPAN module installation guide.