Package oshi.hardware.platform.linux
Class LinuxGlobalMemory
- java.lang.Object
-
- oshi.hardware.common.AbstractGlobalMemory
-
- oshi.hardware.platform.linux.LinuxGlobalMemory
-
- All Implemented Interfaces:
GlobalMemory
@ThreadSafe public final class LinuxGlobalMemory extends AbstractGlobalMemory
Memory obtained by /proc/meminfo and sysinfo.totalram
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Supplier<Pair<java.lang.Long,java.lang.Long>>
availTotal
private static long
PAGE_SIZE
private java.util.function.Supplier<VirtualMemory>
vm
-
Constructor Summary
Constructors Constructor Description LinuxGlobalMemory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private VirtualMemory
createVirtualMemory()
long
getAvailable()
The amount of physical memory currently available, in bytes.long
getPageSize()
The number of bytes in a memory pagelong
getTotal()
The amount of actual physical memory, in bytes.VirtualMemory
getVirtualMemory()
Virtual memory, such as a swap file.private static Pair<java.lang.Long,java.lang.Long>
readMemInfo()
Updates instance variables from reading /proc/meminfo.-
Methods inherited from class oshi.hardware.common.AbstractGlobalMemory
getPhysicalMemory, toString
-
-
-
-
Field Detail
-
PAGE_SIZE
private static final long PAGE_SIZE
-
availTotal
private final java.util.function.Supplier<Pair<java.lang.Long,java.lang.Long>> availTotal
-
vm
private final java.util.function.Supplier<VirtualMemory> vm
-
-
Method Detail
-
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.- Returns:
- A VirtualMemory object.
-
readMemInfo
private static Pair<java.lang.Long,java.lang.Long> readMemInfo()
Updates instance variables from reading /proc/meminfo. While most of the information is available in the sysinfo structure, the most accurate calculation of MemAvailable is only available from reading this pseudo-file. The maintainers of the Linux Kernel have indicated this location will be kept up to date if the calculation changes: see https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/? id=34e431b0ae398fc54ea69ff85ec700722c9da773Internally, reading /proc/meminfo is faster than sysinfo because it only spends time populating the memory components of the sysinfo structure.
- Returns:
- A pair containing available and total memory in bytes
-
createVirtualMemory
private VirtualMemory createVirtualMemory()
-
-