hammerspoon2-docs
    Preparing search index...

    Function memoryUsage

    • How physical memory is being used right now, in bytes.

      The fields match the kernel's accounting (what vm_stat prints, converted from pages to bytes). Little memory is ever "free" on macOS, since the system keeps recently used files in memory until something else needs it, so appMemory is usually the most useful figure. Activity Monitor's "Memory Used" is appMemory + wired + compressed.

      Returns
          | {
              active: number;
              appMemory: number;
              cachedFiles: number;
              compressed: number;
              free: number;
              inactive: number;
              purgeable: number;
              speculative: number;
              total: number;
              wired: number;
          }
          | null

      How memory is being used, or null if macOS wouldn't say

      • {
            active: number;
            appMemory: number;
            cachedFiles: number;
            compressed: number;
            free: number;
            inactive: number;
            purgeable: number;
            speculative: number;
            total: number;
            wired: number;
        }
        • active: number

          Memory in use that has been used recently

        • appMemory: number

          Memory used by apps and processes (Activity Monitor's "App Memory")

        • cachedFiles: number

          Memory holding file contents that can be dropped if needed (Activity Monitor's "Cached Files")

        • compressed: number

          Memory used to hold compressed data (Activity Monitor's "Compressed")

        • free: number

          Memory not being used for anything

        • inactive: number

          Memory in use that hasn't been used recently, and can be reclaimed

        • purgeable: number

          Memory apps have marked as safe for the system to discard

        • speculative: number

          Memory holding data read ahead of time, in case it's needed

        • total: number

          The physical memory installed

        • wired: number

          Memory the kernel has locked in place, which can't be compressed or swapped out

      • null