*/
public WOActionResults forceGCAction() {
if (canPerformActionWithPasswordKey("er.extensions.ERXGCPassword")) {
ERXStringHolder result = pageWithName(ERXStringHolder.class);
Runtime runtime = Runtime.getRuntime();
ERXUnitAwareDecimalFormat decimalFormatter = new ERXUnitAwareDecimalFormat(ERXUnitAwareDecimalFormat.BYTE);
decimalFormatter.setMaximumFractionDigits(2);
String info = "Before: ";
info += decimalFormatter.format(runtime.maxMemory()) + " max, ";
info += decimalFormatter.format(runtime.totalMemory()) + " total, ";
info += decimalFormatter.format(runtime.totalMemory()-runtime.freeMemory()) + " used, ";
info += decimalFormatter.format(runtime.freeMemory()) + " free\n";
int count = 5;
if(request().stringFormValueForKey("count") != null) {
count = Integer.parseInt(request().stringFormValueForKey("count"));
}
ERXExtensions.forceGC(count);
info += "After: ";
info += decimalFormatter.format(runtime.maxMemory()) + " max, ";
info += decimalFormatter.format(runtime.totalMemory()) + " total, ";
info += decimalFormatter.format(runtime.totalMemory()-runtime.freeMemory()) + " used, ";
info += decimalFormatter.format(runtime.freeMemory()) + " free\n";
result.setValue(info);
log.info("GC forced\n"+info);
return result;
}