*/
public interface ProcessMemoryInfo {
- public String toHumanReadableString();
+ /**
+ * @return a non-structured human readable string representation of this instances contents
+ */
+ String toHumanReadableString();
+
+ /**
+ * @return tab-separated row of text containing N columns of explanatory
+ * header text for writing a tab-separated "CSV" file
+ */
+ String headerRow();
+
+ /**
+ * @return tab-separated row of text containing N columns of data values
+ * that match the explanations provided by {@link #headerRow()}
+ */
+ String dataRow();
}
\ No newline at end of file
+ peakRSS + "]";
}
+ @Override
public String toHumanReadableString() {
StringBuilder sb = new StringBuilder();
- sb.append("Memory Use [Current RSS = ").append(currentRSS)
- .append(" MB, Peak RSS = ").append(Util.toMb(peakRSS))
- .append(" MB]");
+ sb.append("RSS ").append(Util.toMb(currentRSS))
+ .append("M / ").append(Util.toMb(peakRSS))
+ .append("M");
return sb.toString();
}
+ @Override
+ public String headerRow() {
+ return "RSS [MB]\tPeak RSS [MB]";
+ }
+
+ @Override
+ public String dataRow() {
+ return Util.toMb(currentRSS) + "\t" + Util.toMb(peakRSS);
+ }
+
+ public static void main(String[] args) {
+ System.out.println(new CMemoryInfo().toHumanReadableString());
+ System.out.println(new CMemoryInfo().headerRow());
+ System.out.println(new CMemoryInfo().dataRow());
+ }
+
}
\ No newline at end of file
+ PeakPagefileUsage + ", PrivateUsage=" + PrivateUsage + "]";
}
+ @Override
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]");
+ sb.append("RSS ").append(Util.toMb(WorkingSetSize))
+ .append("M / ").append(Util.toMb(PeakWorkingSetSize))
+ .append("M").append(Util.NL)
+ .append("Paged/Nonpaged Pool ").append(Util.toKb(QuotaPagedPoolUsage)).append("K / ")
+ .append(Util.toKb(QuotaPeakPagedPoolUsage)).append("K / ")
+ .append(Util.toKb(QuotaNonPagedPoolUsage)).append("K / ")
+ .append(Util.toKb(QuotaPeakNonPagedPoolUsage)).append("K").append(Util.NL)
+ .append("Page File ").append(Util.toMb(PagefileUsage))
+ .append("M / ").append(Util.toMb(PeakPagefileUsage))
+ .append("M (").append(PageFaultCount).append(" faults)");
return sb.toString();
}
+ @Override
+ public String headerRow() {
+ return "RSS [MB]\tPeak RSS [MB]\tPaged Pool Usage [kB]\tPeak Paged Pool Usage [kB]\tNonpaged Pool Usage [kB]\tPeak Nonpaged Pool Usage [kB]\tPage File Usage [MB]\tPeak Page File Usage [MB]\tPage Faults";
+ }
+
+ @Override
+ public String dataRow() {
+ return Util.toMb(WorkingSetSize) + "\t" + Util.toMb(PeakWorkingSetSize)
+ + "\t" + Util.toKb(QuotaPagedPoolUsage) + "\t" + Util.toKb(QuotaPeakPagedPoolUsage)
+ + "\t" + Util.toKb(QuotaNonPagedPoolUsage) + "\t" + Util.toKb(QuotaPeakNonPagedPoolUsage)
+ + "\t" + Util.toMb(PagefileUsage) + "\t" + Util.toMb(PeakPagefileUsage)
+ + "\t" + PageFaultCount;
+ }
+
+ public static void main(String[] args) {
+ System.out.println(new ProcessMemoryCounters().toHumanReadableString());
+ System.out.println(new ProcessMemoryCounters().headerRow());
+ System.out.println(new ProcessMemoryCounters().dataRow());
+ }
+
}
\ No newline at end of file