Class MacGlobalMemory
java.lang.Object
oshi.hardware.common.AbstractGlobalMemory
oshi.hardware.common.platform.mac.MacGlobalMemory
- All Implemented Interfaces:
GlobalMemory
Memory obtained by host_statistics (vm_stat) and sysctl.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract VirtualMemoryCreates the virtual memory instance.longThe amount of physical memory currently available, in bytes.longThe number of bytes in a memory pagePhysical memory, such as banks of memory.longgetTotal()The amount of actual physical memory, in bytes.Virtual memory, such as a swap file.protected abstract longQueries the page size.protected abstract longQueries VM statistics for available memory.protected longQueries a sysctl long value.protected abstract SysctlProviderReturns the sysctl provider for this implementation.Methods inherited from class AbstractGlobalMemory
toString
-
Constructor Details
-
MacGlobalMemory
protected MacGlobalMemory()Default constructor.
-
-
Method Details
-
getAvailable
public long getAvailable()Description copied from interface:GlobalMemoryThe amount of physical memory currently available, in bytes.- Returns:
- Available number of bytes.
-
getTotal
public long getTotal()Description copied from interface:GlobalMemoryThe amount of actual physical memory, in bytes.- Returns:
- Total number of bytes.
-
getPageSize
public long getPageSize()Description copied from interface:GlobalMemoryThe number of bytes in a memory page- Returns:
- Page size in bytes.
-
getVirtualMemory
Description copied from interface:GlobalMemoryVirtual memory, such as a swap file.Operating systems differ significantly in how they manage virtual memory. See the
VirtualMemoryclass documentation for details on Windows commit-charge, Linux overcommit, and macOS compressed-memory models.- Returns:
- A VirtualMemory object.
-
getPhysicalMemory
Description copied from interface:GlobalMemoryPhysical memory, such as banks of memory.On Linux, requires elevated permissions. On FreeBSD and Solaris, requires installation of dmidecode.
- Specified by:
getPhysicalMemoryin interfaceGlobalMemory- Overrides:
getPhysicalMemoryin classAbstractGlobalMemory- Returns:
- A list of PhysicalMemory objects.
-
queryVmStats
protected abstract long queryVmStats()Queries VM statistics for available memory.- Returns:
- available memory in bytes
-
sysctlProvider
Returns the sysctl provider for this implementation.- Returns:
- the sysctl provider
-
sysctl
Queries a sysctl long value.- Parameters:
name- the sysctl namedefaultValue- the default value- Returns:
- the sysctl value
-
queryPageSize
protected abstract long queryPageSize()Queries the page size.- Returns:
- the page size in bytes
-
createVirtualMemory
Creates the virtual memory instance.- Returns:
- the virtual memory
-