I created a program that uses the A * search algorithm to solve 8 puzzles. I was interested to know how much memory is used by my program from start to finish.
So far i have done
At the beginning of the program
static double totalMem = Runtime.getRuntime().totalMemory()/(1024*1024); static double memoryMax = Runtime.getRuntime().maxMemory()/(1024*1024);
and at the end of the program
timeTaken-=System.currentTimeMillis(); System.out.println("\n\n-------Total Time Taken = "+Math.abs(timeTaken)+ " millisec ------\n "); System.out.println("-------Maximum Memory = "+memoryMax+" MB------\n "); System.out.println("-------Total Memory = "+totalMem +" MB------\n "); currMem = Runtime.getRuntime().freeMemory()/(1024*1024); System.out.println("-------Free Memory = "+currMem+" MB------\n "); double memUsed = (Runtime.getRuntime().totalMemory())/(1024*1024)-currMem; System.out.println("-------Total Used = "+memUsed +" MB------\n ");
This does not seem right. When I test different datasets. Any suggestive
source share