def memory
      @pagesize ||= Vmstat.pagesize
      has_available = false

      total = free = active = inactive = pageins = pageouts = available = 0
      procfs_file("meminfo") do |file|
        content = file.read(2048) # the requested information is in the first bytes

        content.scan(/(\w+):\s+(\d+) kB/) do |name, kbytes|
          pages = (kbytes.to_i * 1024) / @pagesize

          case name
            when "MemTotal" then total = pages
            when "MemFree" then free = pages
            when "MemAvailable"
                available = pages
                has_available = true
            when "Active" then active = pages
            when "Inactive" then inactive = pages
          end
        end
      end

      procfs_file("vmstat") do |file|
        content = file.read

        if content =~ /pgpgin\s+(\d+)/
          pageins = $1.to_i
        end

        if content =~ /pgpgout\s+(\d+)/
          pageouts = $1.to_i
        end
      end

      mem_klass = has_available ? LinuxMemory : Memory
      mem_klass.new(@pagesize, total-free-active-inactive, active,
                    inactive, free, pageins, pageouts).tap do |mem|
        mem.available = available if has_available
      end
    end
def memory
      @pagesize ||= Vmstat.pagesize
      has_available = false

      total = free = active = inactive = pageins = pageouts = available = 0
      procfs_file("meminfo") do |file|
        content = file.read(2048) # the requested information is in the first bytes

        content.scan(/(\w+):\s+(\d+) kB/) do |name, kbytes|
          pages = (kbytes.to_i * 1024) / @pagesize

          case name
            when "MemTotal" then total = pages
            when "MemFree" then free = pages
            when "MemAvailable"
                available = pages
                has_available = true
            when "Active" then active = pages
            when "Inactive" then inactive = pages
          end
        end
      end

      procfs_file("vmstat") do |file|
        content = file.read

        if content =~ /pgpgin\s+(\d+)/
          pageins = $1.to_i
        end

        if content =~ /pgpgout\s+(\d+)/
          pageouts = $1.to_i
        end
      end

      mem_klass = has_available ? LinuxMemory : Memory
      mem_klass.new(@pagesize, total-free-active-inactive, active,
                    inactive, free, pageins, pageouts).tap do |mem|
        mem.available = available if has_available
      end
    end
Fetches the memory usage information.
 @return [Vmstat::Memory] the memory data like free, used und total.
 @example
   Vmstat.memory # => #<struct Vmstat::Memory ...>