Measuring performance throughout construction can help to identify major performance problems as quickly as possible, which is almost always beneficial. If a major problem becomes apparent, then some immediate redesign will likely be necessary. If no major problem is apparent, then, if needed, minor optimizations can be performed later, when construction is nearly complete. (Many would argue that worrying about minor optimizations during construction is not advisable, since optimizations can sometimes make code more obscure.)
These monitoring tools come with the JDK:
If the above tools aren't available, then you are stuck with more primitive means of measuring an application's size in memory. They depend on your platform. For example:
ps -e | grep java
", pass it to
pmap
, as in "pmap -x 6598
", and look for total KB entry in the Private columnAs well, the JDK itself comes with basic profiling tools. For example:
Runtime.freeMemory
Runtime.totalMemory
java -Xprof MyClass
java -Xrunhprof:[options] MyClass
vmstat
for Unix hosts, and perfmon
for Windows hosts.