View Javadoc
1   /*
2    * Copyright 2020-2022 The OSHI Project Contributors
3    * SPDX-License-Identifier: MIT
4    */
5   package oshi.driver.unix.aix.perfstat;
6   
7   import com.sun.jna.platform.unix.aix.Perfstat;
8   import com.sun.jna.platform.unix.aix.Perfstat.perfstat_memory_total_t;
9   
10  import oshi.annotation.concurrent.ThreadSafe;
11  
12  /**
13   * Utility to query performance stats for memory
14   */
15  @ThreadSafe
16  public final class PerfstatMemory {
17  
18      private static final Perfstat PERF = Perfstat.INSTANCE;
19  
20      private PerfstatMemory() {
21      }
22  
23      /**
24       * Queries perfstat_memory_total for total memory usage statistics
25       *
26       * @return usage statistics
27       */
28      public static perfstat_memory_total_t queryMemoryTotal() {
29          perfstat_memory_total_t memory = new perfstat_memory_total_t();
30          int ret = PERF.perfstat_memory_total(null, memory, memory.size(), 1);
31          if (ret > 0) {
32              return memory;
33          }
34          return new perfstat_memory_total_t();
35      }
36  }