class Memory
Struct for host memory snapshot. All sizes in bytes. Stored: total_size, used_size, swap_*, reclaimable_size. free_size and available_size are derived.
Nested
Definitions
def to_h
Convert the memory snapshot to a hash, including derived sizes.
Signature
-
returns
Hash(Symbol, Integer | Nil) The memory snapshot fields.
Implementation
def to_h
super.merge(free_size: free_size, available_size: available_size)
end
def to_json(*arguments)
Convert the memory snapshot to JSON.
Signature
-
parameter
argumentsArray Additional arguments passed to the JSON encoder.
-
returns
String The encoded memory snapshot.
Implementation
def to_json(*arguments)
as_json.to_json(*arguments)
end
def free_size
Complement of used: total_size - used_size. Same meaning on all platforms.
Implementation
def free_size
total_size - used_size
end
def available_size
Memory that could be used: free_size plus reclaimable. Use this for "available" when reclaimable_size is set; otherwise equals free_size.
Implementation
def available_size
free_size + (reclaimable_size || 0)
end
def self.zero
Create a zero-initialized Host::Memory instance.
Signature
-
returns
Memory
Implementation
def self.zero
self.new(0, 0, nil, nil, nil)
end
def self.supported?
Whether host memory capture is supported on this platform.
Signature
-
returns
Boolean
Implementation
def self.supported?
false
end
def self.capture
Capture current host memory. Implemented by Host::Memory::Linux or Host::Memory::Darwin (in host/memory/linux.rb, host/memory/darwin.rb).
Signature
-
returns
Memory | Nil A Host::Memory instance, or nil if not supported or capture failed.
Implementation
def self.capture
return nil
end