1 /*
2 * Copyright 2019-2022 The OSHI Project Contributors
3 * SPDX-License-Identifier: MIT
4 */
5 package oshi.hardware;
6
7 import oshi.annotation.concurrent.ThreadSafe;
8
9 /**
10 * The VirtuallMemory class tracks information about the use of a computer's virtual memory (swap file) which
11 * temporarily moves rarely accessed information to a disk or other storage device.
12 */
13 @ThreadSafe
14 public interface VirtualMemory {
15
16 /**
17 * The current size of the paging/swap file(s), in bytes. If the paging/swap file can be extended, this is a soft
18 * limit.
19 *
20 * @return Total swap in bytes.
21 */
22 long getSwapTotal();
23
24 /**
25 * The current memory committed to the paging/swap file(s), in bytes
26 *
27 * @return Swap used in bytes
28 */
29 long getSwapUsed();
30
31 /**
32 * The maximum memory that can be committed by the system without extending the paging file(s), in bytes. Also
33 * called the Commit Limit. If the paging/swap file can be extended, this is a soft limit. This is generally equal
34 * to the sum of the sizes of physical memory and paging/swap file(s).
35 * <p>
36 * On Linux, represents the total amount of memory currently available to be allocated on the system based on the
37 * overcommit ratio, identified as {@code CommitLimit}. This may be higher or lower than the total size of physical
38 * and swap memory depending on system configuration.
39 *
40 * @return Max Virtual Memory in bytes
41 */
42 long getVirtualMax();
43
44 /**
45 * The memory currently committed by the system, in bytes. Also called the Commit Total. This is generally equal to
46 * the sum of the bytes used of physical memory and paging/swap file(s).
47 * <p>
48 * On Windows, committing pages changes this value immediately; however, the physical memory is not charged until
49 * the pages are accessed, so this value may exceed the sum of used physical and paging/swap file memory.
50 *
51 * @return Swap used in bytes
52 */
53 long getVirtualInUse();
54
55 /**
56 * Number of pages read from paging/swap file(s) to resolve hard page faults. (Hard page faults occur when a process
57 * requires code or data that is not in its working set or elsewhere in physical memory, and must be retrieved from
58 * disk.) This property was designed as a primary indicator of the kinds of faults that cause system-wide delays. It
59 * includes pages retrieved to satisfy faults in the file system cache (usually requested by applications) and in
60 * non-cached mapped memory files.
61 *
62 * @return Pages swapped in
63 */
64 long getSwapPagesIn();
65
66 /**
67 * Number of pages written to paging/swap file(s) to free up space in physical memory. Pages are written back to
68 * disk only if they are changed in physical memory, so they are likely to hold data, not code. A high rate of pages
69 * output might indicate a memory shortage. The operating system writes more pages back to disk to free up space
70 * when physical memory is in short supply.
71 *
72 * @return Pages swapped out
73 */
74 long getSwapPagesOut();
75 }