在Java VisualVM中看不到我自己的应用程序方法 [英] Can't see my own application methods in Java VisualVM

查看:95
本文介绍了在Java VisualVM中看不到我自己的应用程序方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试配置我的java应用程序,只是为了找出花费大部分时间的方法。鉴于TPTP的反应很差,我以为我会给Java VisualVM一个机会。



这一切看起来都很简单 - 除了我似乎无法得到任何一致或有用的东西。



我似乎无法看到与我自己的代码有关的任何内容 - 我得到的是一大堆调用java。*方法。



我试过将检测限制在我自己的包中,这似乎减少了检测方法的数量,但我仍然没有好像看到了我自己的。



每次运行时,我都会获得不同数量的方法,从10到1000不等。
我已经尝试在我的应用程序启动时进入睡眠状态,以确保在应用程序开始执行任何有趣操作之前启动并运行VisualVM,以确保在有趣的内容运行时进行分析。 / p>

我是否有必要做些什么来确保我的课程得到检测?
有时间问题吗? .. like,必须等待类加载等?
我也试过两次运行代码的内容,以确保所有代码都被运用...



我刚刚运行一个来自Eclipse的带有main的应用程序。我尝试使用Eclipse集成,以便VisualVM在启动应用程序时启动 - 结果是相同的。
我也尝试将应用程序导出为可运行的应用程序,并从命令行独立运行,而不是通过Eclipse运行 - 结果相同。



我的应用程序不是一个长期运行的Web应用程序等 - 只是一个主要调用我自己的一些类来进行一些处理,然后退出。



我将不胜感激关于我可能做错的任何建议! :)



谢谢!

解决方案

我也在努力使用VisualVM ,这是一个耻辱,因为它的用户界面非常棒,而其分析输出似乎很可怕。你可以在这里看到我的问题。



Java VisualVM为CPU分析提供了奇怪的结果 - 还有其他人遇到过这个吗?



我可以告诉你一些关于VisualVM的奇怪的事情以及它看起来如何进行分析。



VisualVM似乎在计算花费的总时间在方法内(挂钟时间)。我的应用程序中有一个线程启动了许多其他线程,然后立即阻塞等待队列中的消息。 VisualVM不会在探查器中注册此方法,直到其他线程之一发送第一个线程正在等待的消息(当应用程序终止时)。突然,阻塞方法调用占据了分析输出,并被记录为占用应用程序时间的80%以上。



其他分析器,例如JProfiler和Azul使用的分析器不计算阻塞的线程占用分析器的时间。这意味着对性能分析可能不感兴趣(依赖于情境)的阻塞方法会掩盖您对占用CPU时间的代码的看法。



当我是运行我的分析我最终得到



sun.rmi.transport.tcp.TCPTransport $ ConnectionHandler.run()



模糊我的分析,直到该消息回到等待的线程,然后在这两个完全不相关的方法之间共享顶部位置,以及其他各种无法在其他分析器上出现的无趣方法。



其次,我认为非常重要的是方法过滤机制不能像我预期的那样工作。这意味着我无法过滤掉我现在想要追踪的故事。



这不是一个非常有用的答案。我现在看到的解决方案是支付JProfiler - VisualVM对于这项任务似乎不值得信赖。


I'm trying to profile my java app, just to find out the methods in which most time is being spent. Given the poor reactions here to TPTP, I thought I'd give Java VisualVM a go.

It all seemed rather simple to use - except that I can't seem to get anything consistent or useful out of it.

I can't seem to see anything relating to MY OWN code - all I get is a whole bunch of calls to things like java.* methods.

I've tried restricting instrumentation to only my own packages, which seems to cut down the number of methods instrumented, but still I don't ever seem to see my own.

Each time I run, I get varying numbers of methods instrumented, ranging from 10's to 1000's. I've tried putting in a sleep at the start of my app, to make sure I get VisualVM up and running before my app starts to do anything interesting, to make sure it's profiling when the interesting stuff is running.

Is there something I have to do to ensure my classes get instrumented ? Are there timing issues ? ..like, have to wait for classes to be loaded etc ? I've also tried running the guts of the code twice, to make sure all the code does get exercised...

I'm just running an app, with a main, from Eclipse. I've tried using the Eclipse integration so that VisualVM starts up when I start the app - results are the same. I've also tried exporting the app as a runnable app, and running it standalone from the command line, rather than through Eclipse - same result.

My app is not a long running web app etc - just a main that calls some other of my own classes to do some processing, then quits.

I'd be grateful for any advice about what I might be doing wrong ! :)

Thanks !

解决方案

I too am struggling with VisualVM, which is a shame because its user interface is fantastic while its profiling output seems horrific. You can seem my question here.

Java VisualVM giving bizarre results for CPU profiling - Has anyone else run into this?

I can tell you a couple of odd things that I have learned about VisualVM and the way it seems to do its profiling.

VisualVM appears to be counting the total time spent inside a method (wall-clock time). I have a thread in my application which starts a number of other threads and then immediately blocks waiting for a message on a queue. VisualVM will not register this method in the profiler until one of the other threads sends the message the first thread was waiting for (when the application terminates). Suddenly the blocking method call dominates the profiling output and is recorded as taking up more than 80% of the application time.

Other profilers, such as JProfiler and the one used by Azul do not count a blocked thread as taking up time for the profiler. This means that blocking methods which probably aren't interesting (situation dependant) for performance profiling are obscuring your view of that code that is eating your CPU time.

When I am running my profiling I end up with

sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run()

obscuring my profiling right up until that message comes back to the waiting thread and then the top spot is shared between these two totally irrelevant methods, as well as various other uninteresting methods which don't appear on other profilers.

Secondly and I think quite importantly the method filtering mechanism doesn't work as I would have expected. This means that I can't filter out the I am trying to track down what the story is with this right now.

Not a really helpful answer. The solution as I see it right now is to pay for JProfiler - VisualVM just doesn't seem trustworthy for this task.

这篇关于在Java VisualVM中看不到我自己的应用程序方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆