I am trying to monitor the java heap size dynamically. Does anybody know how to get the maximium memory used in the process of running a piece of codes? Does the Runtime.maxMemory() do the trick? Thanks
Runtime.maxMemory()
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
maxMemory()
totalMemory()
1.4m articles
1.4m replys
5 comments
57.0k users