View Javadoc
1   /*
2    * Copyright 2016-2022 The OSHI Project Contributors
3    * SPDX-License-Identifier: MIT
4    */
5   package oshi.hardware;
6   
7   import java.util.List;
8   
9   import oshi.annotation.concurrent.ThreadSafe;
10  
11  /**
12   * The GlobalMemory class tracks information about the use of a computer's physical memory (RAM) as well as any
13   * available virtual memory.
14   */
15  @ThreadSafe
16  public interface GlobalMemory {
17      /**
18       * The amount of actual physical memory, in bytes.
19       *
20       * @return Total number of bytes.
21       */
22      long getTotal();
23  
24      /**
25       * The amount of physical memory currently available, in bytes.
26       *
27       * @return Available number of bytes.
28       */
29      long getAvailable();
30  
31      /**
32       * The number of bytes in a memory page
33       *
34       * @return Page size in bytes.
35       */
36      long getPageSize();
37  
38      /**
39       * Virtual memory, such as a swap file.
40       *
41       * @return A VirtualMemory object.
42       */
43      VirtualMemory getVirtualMemory();
44  
45      /**
46       * Physical memory, such as banks of memory.
47       * <p>
48       * On Linux, requires elevated permissions. On FreeBSD and Solaris, requires installation of dmidecode.
49       *
50       * @return A list of PhysicalMemory objects.
51       */
52      List<PhysicalMemory> getPhysicalMemory();
53  }