-
-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Daniel Berger edited this page Dec 3, 2021
·
1 revision
A Ruby interface for getting memory information.
- Linux
- Windows
- OSX
gem install sys-memory
require 'sys-memory'
p Sys::Memory.memory # Hash of all information
p Sys::Memory.total # Total memory, no swap
p Sys::Memory.total(extended: true) # Total memory, include swap
There's also the free
, used
and load
module methods.
I realize there are some philosophical differences about what constitutes "available memory". I've tried to accomodate both of the approaches to it that I saw debated online. In short, you can choose to include swap memory as part of memory calculations or not as you see fit via an optional argument.
You can also just use Sys::Memory.memory
and collate the various hash data
pieces as you see fit.