Class MacGlobalMemory

java.lang.Object
oshi.hardware.common.AbstractGlobalMemory
oshi.hardware.common.platform.mac.MacGlobalMemory
All Implemented Interfaces:
GlobalMemory

@ThreadSafe public abstract class MacGlobalMemory extends AbstractGlobalMemory
Memory obtained by host_statistics (vm_stat) and sysctl.
  • Constructor Details

    • MacGlobalMemory

      public MacGlobalMemory()
  • Method Details

    • getAvailable

      public long getAvailable()
      Description copied from interface: GlobalMemory
      The amount of physical memory currently available, in bytes.
      Returns:
      Available number of bytes.
    • getTotal

      public long getTotal()
      Description copied from interface: GlobalMemory
      The amount of actual physical memory, in bytes.
      Returns:
      Total number of bytes.
    • getPageSize

      public long getPageSize()
      Description copied from interface: GlobalMemory
      The number of bytes in a memory page
      Returns:
      Page size in bytes.
    • getVirtualMemory

      public VirtualMemory getVirtualMemory()
      Description copied from interface: GlobalMemory
      Virtual memory, such as a swap file.

      Operating systems differ significantly in how they manage virtual memory. See the VirtualMemory class documentation for details on Windows commit-charge, Linux overcommit, and macOS compressed-memory models.

      Returns:
      A VirtualMemory object.
    • getPhysicalMemory

      public List<PhysicalMemory> getPhysicalMemory()
      Description copied from interface: GlobalMemory
      Physical memory, such as banks of memory.

      On Linux, requires elevated permissions. On FreeBSD and Solaris, requires installation of dmidecode.

      Specified by:
      getPhysicalMemory in interface GlobalMemory
      Overrides:
      getPhysicalMemory in class AbstractGlobalMemory
      Returns:
      A list of PhysicalMemory objects.
    • queryVmStats

      protected abstract long queryVmStats()
    • sysctl

      protected abstract long sysctl(String name, long defaultValue)
    • queryPageSize

      protected abstract long queryPageSize()
      Queries the host page size. Implementations should return the page size on success, or 4096L as a fallback on failure.
      Returns:
      the page size in bytes
    • createVirtualMemory

      protected abstract VirtualMemory createVirtualMemory()