How to calculate what is the maximum memory needed to run a program in Java? (used by that program)
what i did: I recorded currentMemory value many times in run time, then subtract the minimum value from the maximum value.
double currentMemory = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())
but the results wasn't convinced comparing with the activity monitor (Mac OS)
(1) Is there a better way to do that? (2) Should I measure the memory before calling garbage collector or after?
thank you for helping.