问题
I am trying to pin down a memory leak problem for my standalone Java program that runs on unix. I have the port and params setup such that I can connect to it using JMX with JConsole or VisualVM already.
Those help a little but unfortunately it doesn't tell you where the memory has gone, it only tells you how much memory is used. I'm looking for a more detailed profiler to help me locate the objects that is eating up my memory. Anyone have any ideas? Preferably one that talks on JMX port so I don't have to reconfig the program. Thanks!
回答1:
If the machine in question have the X11 client libraries installed, AND a reachable ssh server which allows X11 forwarding, AND an X11 server running on your local machine (perhaps http://sourceforge.net/projects/xming/) AND you use a Sun Java 6u10 or later, you can ssh (with either -X or -Y) into the Linux box, and run jvisualvm there while showing its GUI-interface on your local machine.
Running on the same machine allows jvisualvm to attach directly to the running Java process instead of doing all kinds of configuration voodoo.
回答2:
The NetBeans Java Profiler supports profiling of remote JVMs. One can have NetBeans connect to the remote JVM using JMX.
A presentation available on the JavaPassion site provides a few pointers on how to get started.
回答3:
Um... actually, VisualVM has an excellent memory profiler that can tell you not just which objects eat your memory, but also where they're (perhaps inadvertedly) referenced.
Just press the "Heap dump" button on the Monitor tab and be amazed!
回答4:
I looked at several and like YourKit the most.
It was by far the easiest to use and works great with JMX.
来源:https://stackoverflow.com/questions/1468135/is-there-a-remote-profiler-for-java-that-uses-jmx-preferably