How to monitor Java memory usage?
问题 We have a j2ee application running on Jboss and we want to monitor its memory usage. Currently we use the following code System.gc(); Runtime rt = Runtime.getRuntime(); long usedMB = (rt.totalMemory() - rt.freeMemory()) / 1024 / 1024; logger.information(this, \"memory usage\" + usedMB); This code works fine. That means it shows memory curve which corresponds to reality. When we create a big xml file from a DB a curve goes up, after the extraction is finished it goes down. A consultant told us