#navi_header|Java| JDK7以降のみを対象として、2013年7月現在、JavaのProfile技法はどんな状況にあるのか、VisualVMとNetBeansをメインにざっくりと調べたメモです。 個人レベルでのプログラミングの勉強とか、お金ない環境でとりあえずJDKさえあればナントカなる、という状況を想定してるため、商用製品でどんなのがあるかまで調べてないです。 なお実際に試したのはJDK7(7.0.25), NetBeans 7.3.1です。 * VisualVMとNetBeans JDK6の途中からVisualVMという機能がJDKに追加されまして、2013-07時点では今のところJDKさえあれば使えるProfile技法としてメジャーのようです。 元々NetBeansで開発されてた機能が、単体で切りだされたか何かで、とにかくJDK6の途中から使えるようになり、JDK7でも問題なく使えてNetBeansの皆さんどうもありがとうという感じです。 - VisualVM 入門 -- http://visualvm.java.net/ja/gettingstarted.html - Troubleshooting Guide -- http://visualvm.java.net/troubleshooting.html --- "-Xshare:off" の追加とか、ビミョーに嵌りそうなトラブルシュートの一覧。 2008年と古めの記事: - Javaトラブルシューティングツール VisualVM -- http://www.oki-osk.jp/esc/debugtool/visualvm.html - VisualVMでSAStrutsのプロファイリングなど試してみる その1 - 谷本 心 in せろ部屋 -- http://d.hatena.ne.jp/cero-t/20080515/1210871817 JDK7でのVisualVMのドキュメントと、リモートのJVMにJMX接続する際の資料: - VisualVM -- http://docs.oracle.com/javase/jp/7/technotes/guides/visualvm/index.html - Java VisualVM - JMX エージェントへの明示的な接続 -- http://docs.oracle.com/javase/jp/7/technotes/guides/visualvm/jmx_connections.html - Apache Tomcat 6.0 (6.0.37) - Monitoring and Managing Tomcat -- http://tomcat.apache.org/tomcat-6.0-doc/monitoring.html --- Tomcat6での、リモートJMX接続を受け付けるための設定方法が紹介されている。 NetBeans 7.3.1 においては、NetBeansでProfiler機能を使う = VisualVMと同等+NetBeansでのソースコード参照の連携とか色々便利状態と考えて問題無さそうです。 入り口: - NetBeans NetBeans profiler -- https://profiler.netbeans.org/ NetBeansを使ったProfiler入門: - Introduction to Profiling Java Applications in NetBeans IDE -- https://netbeans.org/kb/docs/java/profiler-intro.html --- NetBeansについてくるSwingのサンプルアプリを使ったProfilingのチュートリアル。 - Using Profiling Points in NetBeans IDE -- https://netbeans.org/kb/docs/java/profiler-profilingpoints.html --- "Profiling Points"の使い方の要点。 - NetBeans Magazine, Issue 4 . Advanced Profiling: Theory in Practice with NetBeans IDE -- https://netbeans.org/community/magazine/html/04/profiler.html --- 実際にiTextという現実のプロジェクトを使った実践Profiling解説。 - Java デバッグツール NetBeans Profiler -- http://www.oki-osk.jp/esc/debugtool/netbeans.html ** リモートマシンのJVMのProfileについて VisualVMの仕組みでは、リモートマシン上のJavaアプリをプロファイリングする機能はサポートされていないようです。JVMの監視についてはサポートされていますので、メモリ使用量やスレッドダンプなどについては取得出来るようです。 - Java VisualVM - リモートアプリケーションの操作 -- http://docs.oracle.com/javase/jp/7/technotes/guides/visualvm/applications_remote.html --- "注: Java VisualVM は、リモートアプリケーションの監視情報を取得することはできますが、リモートアプリケーションのプロファイリングを行うことはできません。" ただ、Googleで検索してみると"VisualVM remote profiling"で結構引っかかるんですよね・・・。監視レベルでのメモリとかスレッドダンプの取得も含めて"Profiling"と指しているのか、ヒープのダンプであったりメソッド単位でのCPU使用状況の監視なども含めているのか、良くわかりません。 なお、NetBeans6では、ターゲット側に特別なパッケージを導入することで、リモートのJVMに対してもヒープのダンプ取得や、メソッド単位でのProfilingが使えたようです。 - NetBeans ProfilerによるTomcatのリモートプロファイリング -- http://www.oki-osk.jp/esc/debugtool/netbeans6.html - NetBeans Profiler: Downloads -- https://netbeans.org/projects/profiler/downloads/directory/remote-packs --- "remote-packs"の更新状況が、3年以上前になっていて、JDK7の今でも適用出来るのか不安。 VisualVMで粒度の細かいプロファイリングをリモートJVMに対して行う手法について、今回は調べきれませんでした。商用製品とかであれば対応してくれたりするのでしょうか・・・。 * Eclipse, IntelliJ IDEAとの連携 Eclipseですと、"Eclipse TPTP"というプロジェクトがあって、こちらでプロファイリング機能が開発されているようです。 - Eclipse Test & Performance Tools Platform Project -- http://www.eclipse.org/tptp/ VisualVMとの連携ですが、いくつか専用のプラグインが開発されたりしているようです。 - Eclipse launcher for VisualVM : "VisualVM Eclipse Plugin"というのを開発しているようです。 -- https://visualvm.java.net/eclipse-launcher.html - java - How to run VisualVM Eclipse Plugin - Stack Overflow -- http://stackoverflow.com/questions/16587711/how-to-run-visualvm-eclipse-plugin - jvmmonitor - Java profiler integrated with Eclipse - Google Project Hosting : VisualVMと密に連携する独自のEclipse Pluginのようです。 -- https://code.google.com/a/eclipselabs.org/p/jvmmonitor/ - JVM Monitor documentation -- http://www.jvmmonitor.org/doc/index.html IntelliJ IDEAのPluginリポジトリで見つけた、プロファイリング系のPlugin: - JetBrains Plugin Repository :: IntelliPROF -- http://plugins.jetbrains.com/plugin/1858?pr=idea --- 公式解説ページが404・・・ - JetBrains Plugin Repository :: VisualVM Profiler -- http://plugins.jetbrains.com/plugin/3749?pr=idea --- VisualVMに対応してるっぽいです。 - JetBrains Plugin Repository :: JProfiler -- http://plugins.jetbrains.com/plugin/253?pr=idea --- "JProfiler"という商用製品と連携するための公式プラグインのようです。 --- http://www.ej-technologies.com/products/jprofiler/overview.html #navi_footer|Java|