-
Notifications
You must be signed in to change notification settings - Fork 0
/
Memory.pde
30 lines (22 loc) · 1.27 KB
/
Memory.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public class Memory {
public void printMemoryUsage() {
int mb = 1024 * 1024;
// get Runtime instance
Runtime instance = Runtime.getRuntime();
//printToFile.printDebugLine(this, "***** Heap utilization statistics [MB] *****\n", 1);
// available memory
printToFile.printDebugLine(this, "Total Memory: " + instance.totalMemory() / mb +
" Free Memory: " + instance.freeMemory() / mb +
" Used Memory: " + (instance.totalMemory() - instance.freeMemory()) / mb +
//" Used Memory: " + (instance.totalMemory() - instance.freeMemory()) +
" Max Memory: " + instance.maxMemory() / mb + (instance.totalMemory() - instance.freeMemory()) / mb, 1);
}
public void printUsedMemory(String info)
{
int mb = 1024 * 1024;
// get Runtime instance
Runtime instance = Runtime.getRuntime();
// Insert a comma - then allows these output lines to be put into a spreadsheet so can graph memory usage
printToFile.printDebugLine(this, "\"" + info + "\"," + (instance.totalMemory() - instance.freeMemory()) / mb, 1);
}
}