[JAVA] [C#] how to calculate the maximum memory usage of a data mining algorithm
Hello,
Today, I received a question today about how to compute the maximum memory of a data mining algorithm like FPGrowth in Java.
It is very simple. I do like that.
I add a variable :
double maxMemory = 0;
Then I copy and paste this method:
private void checkMemory() {
double currentMemory = ((double) ((double) (Runtime.getRuntime()
.totalMemory() / 1024) / 1024))
- ((double) ((double) (Runtime.getRuntime().freeMemory() / 1024) / 1024));
if (currentMemory > maxMemory) {
maxMemory = currentMemory;
}
}
Then, I call the method
checkMemory()
from where I want to check the memory.
Finally, I print the result:
System.out.println("memory : " + maxMemory);
Philippe
Edited 2 time(s). Last edit at 05/08/2012 05:39PM by webmasterphilfv.