I've tried VisualVM and JVM Monitor so far, and neither have behaved as I need them to. A short synopsis of my program: I need to measure a fast application with subsecond precision across 5+ threads. By the time I can select "Start Profiling", my application has ended. As a workaround, I put System.in.read() at the end of my application, but this means that everything from the read onwards is garbage information and skews some of the measurements.

JVM Monitor especially should start automatically profiling on the launch of every application, being embedded into Eclipse.

有帮助吗?

解决方案

From the manual: http://www.jvmmonitor.org/doc/#How_to_monitor_app_that_runs_for_short_time

How can I monitor my application that runs only for very short time?

To monitor the application that runs for so short time that you cannot connect JVM Monitor,

Set a break point at point of interest, and run your application with debug mode.
Connect JVM Monitor to the application while stopped at break point.
Collect profiling data with JVM Monitor.

Note: If your application is started from outside Eclipse, you may specify the following option for your application to suspend until debugger is attached.

-agentlib:jdwp=transport=dt_socket,address=<port number>,server=y,suspend=y

其他提示

There is a new plugin Startup Profiler for VisualVM 1.3.6. It allows you to profile your application from the beginning.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top