Measuring the memory usage of a algorithm
My question is, how can you measure how much memory a algorithm (implemented as a Java method) uses?
It's straightforward to measure the duration of this method call and also easy to measure and also easy to see how much memory is allocated before and after a method call. But what I want to measure, is how much memory is used during the method call.
I have written a library for scaling BufferedImages using resampling ( http://code.google.com/p/java-image-scaling/ ). This algorithm is uses a lot of heap memory (so you need to adjust your maximum heap to scale large images). I have tried a few things to improve the memory usage, but I find it really difficult to test if my changes has any effect.