macos Mac OS X 上的 Java Profiler 工具
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1659243/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java Profiler tool on Mac OS X
提问by Ali
I'm developing both a Java app and J2EE webapp using Eclipse Europa on Mac OS X 10.5.8. The webapp provides a RESTful API layer for the Java app I've written. I'm running the webapp using tomcat from inside Eclipse.
我正在 Mac OS X 10.5.8 上使用 Eclipse Europa 开发 Java 应用程序和 J2EE web 应用程序。webapp 为我编写的 Java 应用程序提供了一个 RESTful API 层。我正在 Eclipse 中使用 tomcat 运行 webapp。
It seems like there are some serious performance issues and I would like to use a profiler to narrow down on these problems, but I haven't been able to find anything decent to work with. I've looked at the following options:
似乎存在一些严重的性能问题,我想使用分析器来缩小这些问题的范围,但我找不到任何合适的工作。我查看了以下选项:
- TPTP, ships with Eclipse: A known bug prevents the profiler from running on Mac :(
- JProfiler: doesn't have a Mac version
- Profiler4J: Installed it, but couldn't get it to work
- Shark: comes with MacOSX, but when I choose "Java Time Profile" and run my webapp, it doesn't allow me to choose any processes to profile
- Other tools I looked at cost a lot of $$ and this is an open-source project
- TPTP,与 Eclipse 一起提供:一个已知的错误阻止了分析器在 Mac 上运行 :(
- JProfiler:没有 Mac 版本
- Profiler4J:已安装,但无法正常工作
- Shark:MacOSX 自带,但是当我选择“Java 时间配置文件”并运行我的 web 应用程序时,它不允许我选择任何进程来配置文件
- 我查看的其他工具花费了很多美元,这是一个开源项目
I've looked through this list: here but there are too many choices and too little time to go through them ALL!!
我已经浏览了这个列表:这里但是有太多的选择和太少的时间来完成它们!
Does anyone know of an easy-to-use visual Java profiler that actually works on Mac, given my environment? I would love to hear your suggestions.
考虑到我的环境,有谁知道在 Mac 上实际工作的易于使用的可视化 Java 分析器?我很想听听你的建议。
Thanks a lot guys, Ali
非常感谢大家,阿里
采纳答案by Pascal Thivent
Maybe you could give VisualVMa try, if Java 6 is an option. This nice Setting up Sun's VisualVM on Mac OSXblog post explains how to get it working on Mac OSX.
如果 Java 6 是一个选项,也许您可以尝试一下VisualVM。这篇不错的在 Mac OSX 上设置 Sun 的 VisualVM博客文章解释了如何让它在 Mac OSX 上运行。
Or get an open source license for Yourkitwhich is indeed a very good tool as Malaxeurpointed out.
回答by zvikico
I'm using JProfileron Mac OS X and I'm very happy with it. I don't know why you wrote that it doesn't support OS X, they even have a DMG download on their site. It is an expensive piece of software - I would suggest contacting their sales. Most companies are happy to donate licenses to open source projects.
我在 Mac OS X 上使用JProfiler,我对它非常满意。我不知道你为什么写它不支持 OS X,他们甚至在他们的网站上有 DMG 下载。这是一个昂贵的软件 - 我建议联系他们的销售。大多数公司乐于向开源项目捐赠许可证。
Shark is the old tool. The latest XCode comes with Instruments. A gorgeously designed profiling application based on DTrace. It can profile Java application, but you won't come close to the level of details you will get with tools built to instrument Java.
鲨鱼是旧工具。最新的 XCode 随仪器一起提供。一个基于 DTrace 的设计华丽的分析应用程序。它可以分析 Java 应用程序,但您不会接近使用为检测 Java 而构建的工具所能获得的详细程度。
Another option is to use TPTP. The Eclipse plugin works on OS X, but the agent controller does not. You can run a virtualized Linux (I use VMWare Fusion, but you can use the FOSS alternative, Virtualbox) and run your Tomcat there. You can connect the TPTP on the OS X and profile the application running on the Linux box.
另一种选择是使用 TPTP。Eclipse 插件适用于 OS X,但代理控制器不适用。您可以运行虚拟化的 Linux(我使用 VMWare Fusion,但您可以使用 FOSS 替代方案 Virtualbox)并在那里运行您的 Tomcat。您可以在 OS X 上连接 TPTP 并配置在 Linux 机器上运行的应用程序。
回答by Malaxeur
I'd recommend Yourkit. It's by far the best Java profiler I have used (although it's somewhat costly).
我会推荐Yourkit。它是迄今为止我用过的最好的 Java 分析器(虽然它有点贵)。
Although it costs money, you can get trial licenses.
虽然它需要花钱,但您可以获得试用许可证。
Edit: Looks like they offer an Open Source license (for free). If you can get it, go for it: http://www.yourkit.com/purchase/index.jsp
编辑:看起来他们提供开源许可证(免费)。如果你能得到它,去吧:http: //www.yourkit.com/purchase/index.jsp
回答by Justin Voskuhl
Be aware that Shark does not work with Java running in 64-bit mode. With OS X 10.6 java runs in 64-bit by default. If you give java the "-d32" flag when it starts, it will run in 32 bit mode. Combine this with the "-agentlib:Shark" flag, and then start Shark. You now should be able to profile your Java program using OS X 10.6 and Shark. If profiling Java in 32-bit mode is acceptable, then this might be of use to you.
请注意,Shark 不适用于以 64 位模式运行的 Java。在 OS X 10.6 中,java 默认以 64 位运行。如果在启动时给 java 一个“-d32”标志,它将以 32 位模式运行。将其与“-agentlib:Shark”标志结合起来,然后启动 Shark。您现在应该能够使用 OS X 10.6 和 Shark 来分析您的 Java 程序。如果在 32 位模式下分析 Java 是可以接受的,那么这可能对您有用。
回答by TofuBeer
I am not sure how hard it would be to get the project working under Netbeans... but if you can do that without much trouble then the profiler should work without issue.
我不确定让项目在 Netbeans 下工作会有多困难……但如果你能轻松做到这一点,那么分析器应该可以毫无问题地工作。
VisualVM and Yourkit, as pointed out by the others here, are both good as well.
正如其他人所指出的,VisualVM 和 Yourkit 也都不错。