4

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.

NobleUplift
  • 5,631
  • 8
  • 45
  • 87

2 Answers2

2

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
Johan
  • 74,508
  • 24
  • 191
  • 319
  • I went through that whole page and missed the very bottom of it. Well then. – NobleUplift Oct 09 '13 at 21:15
  • Lack of caffeine in your bloodstream. You must always keep the java levels in your body and on your screen in balance. – Johan Oct 09 '13 at 21:17
  • That is definitely true. I'm dragging something awful today. Also, I'm assuming JVM Monitor wants you to put a breakpoint at the end of your code as well? – NobleUplift Oct 09 '13 at 21:26
  • NO there should not be a need for an end-breakpoint. But do experiment. – Johan Oct 09 '13 at 21:47
  • 1
    Profiling a short lived application will tell you more about the JVM startup than the application itself. Starting the application in debug mode will skew the results even more. – JB- Jan 04 '14 at 12:43
2

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

Tomas Hurka
  • 6,723
  • 29
  • 38