static long bytesAllocated(Runnable etc r) { if (!threadAllocatedMemorySane()) ret -1; long value1 = bytesAllocatedByCurrentThread(); pcall { if (r != null) r.run(); } long value2 = bytesAllocatedByCurrentThread(); ret value2-value1; }