1 package org.simantics.nativemem;
\r
3 import org.simantics.nativemem.internal.Arch;
\r
4 import org.simantics.nativemem.internal.OS;
\r
5 import org.simantics.nativemem.internal.Psapi32;
\r
6 import org.simantics.nativemem.internal.Psapi64;
\r
8 import com.sun.jna.platform.win32.Kernel32;
\r
9 import com.sun.jna.platform.win32.WinNT.HANDLE;
\r
12 public class NativeMem {
\r
16 * the structure to write the result into or <code>null</code> to
\r
17 * create a new structure
\r
18 * @return the result structure
\r
20 public static ProcessMemoryCounters getMemoryCounters(ProcessMemoryCounters out) {
\r
22 out = new ProcessMemoryCounters();
\r
24 OS os = OS.calculate();
\r
25 Arch arch = Arch.calculate();
\r
28 HANDLE proc = Kernel32.INSTANCE.GetCurrentProcess();
\r
31 Psapi32.PROCESS_MEMORY_COUNTERS_EX pmem = new Psapi32.PROCESS_MEMORY_COUNTERS_EX();
\r
32 boolean ok = Psapi32.INSTANCE.GetProcessMemoryInfo(proc, pmem, pmem.size());
\r
39 Psapi64.PROCESS_MEMORY_COUNTERS_EX pmem = new Psapi64.PROCESS_MEMORY_COUNTERS_EX();
\r
40 boolean ok = Psapi64.INSTANCE.GetProcessMemoryInfo(proc, pmem, pmem.size());
\r
47 throw new UnsupportedOperationException("Architecture " + arch + " not supported on operating system " + os);
\r
52 throw new UnsupportedOperationException("Operating system " + os + " not supported");
\r