]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.nativemem/src/org/simantics/nativemem/internal/win/ProcessMemoryCounters.java
Rudimentary Linux and MacOSX support for org.simantics.nativemem
[simantics/platform.git] / bundles / org.simantics.nativemem / src / org / simantics / nativemem / internal / win / ProcessMemoryCounters.java
diff --git a/bundles/org.simantics.nativemem/src/org/simantics/nativemem/internal/win/ProcessMemoryCounters.java b/bundles/org.simantics.nativemem/src/org/simantics/nativemem/internal/win/ProcessMemoryCounters.java
new file mode 100644 (file)
index 0000000..9c68a54
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2016, 2017 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.nativemem.internal.win;
+
+import org.simantics.nativemem.ProcessMemoryInfo;
+import org.simantics.nativemem.internal.Util;
+
+/**
+ * Architecture-independent version of the Windows PsApi PROCESS_MEMORY_COUNTERS
+ * structure.
+ * 
+ * @author Tuukka Lehtonen
+ */
+public class ProcessMemoryCounters implements ProcessMemoryInfo {
+    public int PageFaultCount;
+    public long PeakWorkingSetSize;
+    public long WorkingSetSize;
+    public long QuotaPeakPagedPoolUsage;
+    public long QuotaPagedPoolUsage;
+    public long QuotaPeakNonPagedPoolUsage;
+    public long QuotaNonPagedPoolUsage;
+    public long PagefileUsage;
+    public long PeakPagefileUsage;
+    public long PrivateUsage;
+
+    @Override
+    public String toString() {
+        return "ProcessMemoryCounters [PageFaultCount="
+                + PageFaultCount + ", PeakWorkingSetSize=" + PeakWorkingSetSize
+                + ", WorkingSetSize=" + WorkingSetSize
+                + ", QuotaPeakPagedPoolUsage=" + QuotaPeakPagedPoolUsage
+                + ", QuotaPagedPoolUsage=" + QuotaPagedPoolUsage
+                + ", QuotaPeakNonPagedPoolUsage=" + QuotaPeakNonPagedPoolUsage
+                + ", QuotaNonPagedPoolUsage=" + QuotaNonPagedPoolUsage
+                + ", PagefileUsage=" + PagefileUsage + ", PeakPagefileUsage="
+                + PeakPagefileUsage + ", PrivateUsage=" + PrivateUsage + "]";
+    }
+
+    public String toHumanReadableString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("ProcessMemoryCounters [\n\tPageFaultCount             = ").append(PageFaultCount)
+        .append(",\n\tPeakWorkingSetSize         = ").append(Util.toMb(PeakWorkingSetSize))
+        .append(" MB,\n\tWorkingSetSize             = ").append(Util.toMb(WorkingSetSize))
+        .append(" MB,\n\tQuotaPeakPagedPoolUsage    = ").append(Util.toMb(QuotaPeakPagedPoolUsage))
+        .append(" MB,\n\tQuotaPagedPoolUsage        = ").append(Util.toMb(QuotaPagedPoolUsage))
+        .append(" MB,\n\tQuotaPeakNonPagedPoolUsage = ").append(Util.toMb(QuotaPeakNonPagedPoolUsage))
+        .append(" MB,\n\tQuotaNonPagedPoolUsage     = ").append(Util.toMb(QuotaNonPagedPoolUsage))
+        .append(" MB,\n\tPagefileUsage              = ").append(Util.toMb(PagefileUsage))
+        .append(" MB,\n\tPeakPagefileUsage          = ").append(Util.toMb(PeakPagefileUsage))
+        .append(" MB,\n\tPrivateUsage               = ").append(Util.toMb(PrivateUsage))
+        .append(" MB]");
+        return sb.toString();
+    }
+
+}
\ No newline at end of file