VisualVM launcher error

前端 未结 4 2532
甜味超标
甜味超标 2021-02-20 00:59

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

相关标签:
4条回答
  • 2021-02-20 01:01

    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.

    0 讨论(0)
  • 2021-02-20 01:14

    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!

    0 讨论(0)
  • 2021-02-20 01:14

    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.

    0 讨论(0)
  • 2021-02-20 01:27

    On Windows, run Eclipse as Administrator.

    0 讨论(0)
提交回复
热议问题