VisualVM launcher error
Asked Answered
C

5

15

I'm trying to use the Eclipse VisualVM launcher. It seems pretty nice, except that it seems to spawn an instance if VisualVM too late to do any profiling of my application. My application finishes execution before the profiler is even initialized; once it starts up, an error window pops up, saying: cannot open requested application. It then shows VM running Eclipse (labeled "org.eclipse.equinox.launcher.Main"). How can I get it to wait for my application and do proper profiling?

Chert answered 9/8, 2012 at 21:6 Comment(0)
Z
13

I know that problem. The only poor man's solution I always came up with is:

  1. Set a breakpoint in your source code
  2. Start your program in debug mode
  3. Connect the profiler
  4. Let the program continue

It just takes a bit time for VisualVM to inject the profiling agent into your VM and I am pretty sure that it allows only remote profiling.

As an alternative you could use YourKit, it can profile your application from the very start. This way the profiling agent is injected on VM startup:

java -agentpath:c:\yourkit\yjpagent.dll FooClass

I am curious why VisualVM does not offer this option, since its technically possible. Anyway I think the debug trick is a good solution from within Eclipse, unless you are also interested in the class loading etc.

Ziwot answered 9/8, 2012 at 21:16 Comment(6)
Couldn't you just Thread.sleep() while it's working itself out?Platter
@RyanAmos That's also possible, I have done this before I came over the trick with Debug Mode. I didn't like to time it together with Timer.sleep, either your have to wait until sleep wears off or the attaching does take too long.Ziwot
YourKit is too expensive. Thanks for the help!Chert
@NateGlenn For commerical use you mean?Ziwot
For the current problem, yeah. I do need a profiler for academic occasions as well.Chert
Thank you! The cost of setting a simple breakpoint is very worthwhile :-)Libbielibbna
O
17

This is probably too late, but I had the same problem, and setting a breakpoint and then starting in debugging mode didn't help at all. I eventually found out that VisualVM saves its temporary data in the folder %TMP%/hsperfdata_[username], on my Windows machine that folder was C:\Users\Jacob\AppData\Local\Temp\hsperfdata_Jacob for instance. It turned out that the process did not have sufficient permissions to access that folder, so I relaxed the permissions on it and now it works just fine. Hope this is useful for someone having the same problem!

Opprobrium answered 9/9, 2012 at 7:41 Comment(2)
In my case I was on Windows 10 and my user name contained capital letters that were not represented in hsperfdata. After renaming the folder with the correct user name, everything worked.Juvenal
outstanding, thxAbecedary
Z
13

I know that problem. The only poor man's solution I always came up with is:

  1. Set a breakpoint in your source code
  2. Start your program in debug mode
  3. Connect the profiler
  4. Let the program continue

It just takes a bit time for VisualVM to inject the profiling agent into your VM and I am pretty sure that it allows only remote profiling.

As an alternative you could use YourKit, it can profile your application from the very start. This way the profiling agent is injected on VM startup:

java -agentpath:c:\yourkit\yjpagent.dll FooClass

I am curious why VisualVM does not offer this option, since its technically possible. Anyway I think the debug trick is a good solution from within Eclipse, unless you are also interested in the class loading etc.

Ziwot answered 9/8, 2012 at 21:16 Comment(6)
Couldn't you just Thread.sleep() while it's working itself out?Platter
@RyanAmos That's also possible, I have done this before I came over the trick with Debug Mode. I didn't like to time it together with Timer.sleep, either your have to wait until sleep wears off or the attaching does take too long.Ziwot
YourKit is too expensive. Thanks for the help!Chert
@NateGlenn For commerical use you mean?Ziwot
For the current problem, yeah. I do need a profiler for academic occasions as well.Chert
Thank you! The cost of setting a simple breakpoint is very worthwhile :-)Libbielibbna
S
8

On Windows, run Eclipse as Administrator.

Schipperke answered 12/8, 2013 at 13:21 Comment(3)
This worked great for me on Windows 8. Thanks Andres!Forefoot
what about eclipse on macOS ?Clancy
This answer should be on top, it takes 5 seconds to try it before all the weird workarounds.Cattish
K
0

This is a dumb solution, but works. Here it goes:

Add an infinite loop wrapper to your application, say "while(true) { your_app }".

The timing noises will also even out as your program runs longer.

Kampmann answered 21/9, 2013 at 20:21 Comment(0)
R
0

I run into the same issue,running in win11 The solution is simple right click VisualVm.exe with Administrator mode. If you still can't see procedure in VisualVm,maby it is your application run too short try Thread.sleep(5000)--Java

Recency answered 18/8, 2024 at 13:25 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.