I am not sure how to assess the memory heap requirements of a
Java program (a Spring & Hibernate
Tomcat Web Application a it happens).
I've tried measuring the memory usage at the point of most usage (some batch processing) but the results are fairly meaningless.
I used runtime.totalMemory - runtime.freeMemory just after a garbage collect.
Given that a gc is only a suggestion and may not have completed by the time I do the measurement I guess it is hardly surprising.
Watching the memory usage in a profiler / monitoring tool is fairly pointless too since Java will continue to use memory until a garbage collect - the apparant memory usage is a function of the max heap size. The more I give it the more it uses.
I'm left wondering if the only recourse is to choose a very small heap size and see if the software actually runs? Slowly increasing/decreasing the maximum until I get a result.
The other alternative appears to be a memory dump, but I'm not convinced I will be able to time this exactly or understand the results (I'd probably use MAT).
I'm developing in Eclipse if that makes a difference.
Reg