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