Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
Hi all,
I want to calculate the memory consumption in order to test the performance of my algorithm.
I am using jdk1.5.0_14 and trying to measure the memory of any array and Queue(provided by java API) using buit-in functions
"Runtime.getRuntime().totalMemory()and Runtime.getRuntime().freeMemory()." I am calculating the memory before defining an array and again calculate it after defining array and then calculate the difference of both to find the used memory.
But it is surprised that it shows me more as my expectation and even some time shows zero or same memory while I am creating multiple arrays.
Can anybody help me that how I can measure the exact memory consumed by all of objects in my algorithm?
Waiting for nice reply!!