1
2
3
4
5 package oshi.hardware.platform.unix.aix;
6
7 import java.util.function.Supplier;
8
9 import com.sun.jna.platform.unix.aix.Perfstat.perfstat_memory_total_t;
10
11 import oshi.annotation.concurrent.ThreadSafe;
12 import oshi.hardware.common.AbstractVirtualMemory;
13
14
15
16
17 @ThreadSafe
18 final class AixVirtualMemory extends AbstractVirtualMemory {
19
20
21 private final Supplier<perfstat_memory_total_t> perfstatMem;
22
23
24
25 private static final long PAGESIZE = 4096L;
26
27
28
29
30
31
32 AixVirtualMemory(Supplier<perfstat_memory_total_t> perfstatMem) {
33 this.perfstatMem = perfstatMem;
34 }
35
36 @Override
37 public long getSwapUsed() {
38 perfstat_memory_total_t perfstat = perfstatMem.get();
39 return (perfstat.pgsp_total - perfstat.pgsp_free) * PAGESIZE;
40 }
41
42 @Override
43 public long getSwapTotal() {
44 return perfstatMem.get().pgsp_total * PAGESIZE;
45 }
46
47 @Override
48 public long getVirtualMax() {
49 return perfstatMem.get().virt_total * PAGESIZE;
50 }
51
52 @Override
53 public long getVirtualInUse() {
54 return perfstatMem.get().virt_active * PAGESIZE;
55 }
56
57 @Override
58 public long getSwapPagesIn() {
59 return perfstatMem.get().pgspins;
60 }
61
62 @Override
63 public long getSwapPagesOut() {
64 return perfstatMem.get().pgspouts;
65 }
66 }