有我的代码:
import com.sun.jna.Native;
PROCESS_MEMORY_COUNTERS pmem = new PROCESS_MEMORY_COUNTERS();
boolean success = PSAPI.GetProcessMemoryInfo(kernel32.GetCurrentProcess(), pmem, pmem.size());
if (!success){
int err=Native.getLastError();
System.out.println("GetProcessMemoryInfo failed:" + err);
}
结构是PSAPI级:
public static class PROCESS_MEMORY_COUNTERS extends Structure {
public int cb;
public int PageFaultCount;
public int PeakWorkingSetSize;
public int WorkingSetSize;
public int QuotaPeakPagedPoolUsage;
public int QuotaPagedPoolUsage;
public int QuotaPeakNonPagedPoolUsage;
public int QuotaNonPagedPoolUsage;
public int PagefileUsage;
public int PeakPagefileUsage;
@Override
protected List getFieldOrder() {
return null;
}
}
PSAPI级声明:
boolean GetProcessMemoryInfo(Pointer process, int pmem, int cb);
这段代码是否正确?
GetProcessMemoryInfo()函数需要指向 pmem 变量的指针,但我不知道如何在Java中实现这个指针:PSAPI.GetProcessMemoryInfo(kernel32.GetCurrentProcess(), pmem, pmem.size());
我希望你的帮助。谢谢!