I am trying to monitor the java heap size dynamically. Does anybody know how to get the maxmium memory used in the process of running a piece of codes? Does the Runtime.maxMemory() do the trick? Thanks
maxMemory()
returns the maximum amount of memory that java will use. So That will not get you what you want. totalMemory()
is what you are looking for though. See The docs