Class: MemoryLocker

Inherits:
Object
  • Object
show all
Defined in:
lib/memory_locker.rb,
lib/memory_locker/version.rb

Overview

Lock process memory, so it won’t be swapped by the kernel. It is implemented as a one-way operation: there is no unlock. That’s because it’s hard to properly clean memory in Ruby.

Constant Summary collapse

Error =
Class.new StandardError
LockingError =
Class.new Error
UnsupportedError =
Class.new Error
VERSION =
"1.0.3"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.callObject



23
24
25
# File 'lib/memory_locker.rb', line 23

def self.call
  new.send :call
end

Instance Method Details

#callObject

Raises:



19
20
21
# File 'lib/memory_locker.rb', line 19

def call
  raise LockingError, "Locking of memory failed" unless function.call(MCL_CURRENT | MCL_FUTURE).zero?
end