Skip to content

faq 130809857

Billy Charlton edited this page Sep 5, 2018 · 2 revisions

Experiences with Java profilers?

by Kai Nagel on 2017-12-10 23:27:38


Can anybody report (good or bad) experiences with profilers for Java? The experiences don't have to be with MATSim, but I want to use it for MATSim and related ...


Comments: 5


Re: Experiences with Java profilers?

by Amit Agarwal on 2017-12-11 06:47:21

Some time ago, I have tried JProfiler which is not an open-source application however, I managed to get a license for 2 months (academic purpose). It took me some time to understand (may be just my lack of profiling skills) but overall I found it good for my part of work. It can be integrated within an IDE (probably, it's possible with all other profilers too).


Re: Experiences with Java profilers?

by Joschka Bischoff on 2017-12-11 07:01:12

I'm using visualVM and find it pretty useful. It's open source, etc.

It can (rarely) happen that profiling does not work for mysterious reasons.


Re: Experiences with Java profilers?

by Marcel Rieser on 2017-12-11 19:34:32

I worked with VisualVM (or JVisualVM as it is included in the default JDK installation). It provides basic functionality (memory snapshots, CPU profiling, thread overview). It works best for long running applications and one typically has to start the application, and then connect from VisualVM to the running process to start profiling. It is thus nearly impossible to profile the application startup. There are some IDE integrations, but at the last time I used it (>2 years ago, with Eclipse) I was not really satisfied with it.

Several years ago at VSP, and more recently at Senozon, we used YourKit, a commercial product (but they would provide free licenses to open source projects), which I really liked. It comes with very good IDE integration (Eclipse, IntelliJ, and likely others) and offers a broad range of functionality. CPU profiling results can be filtered, it tries to find hot methods etc. Memory profiling offers a broad range of inspections/analyses to find memory leaks or possible optimizations, like duplicate Objects, nearly-empty collections and arrays, and other things.

If one is interested in memory analysis only, Eclipse Memory Analyzer is also a useful, freely available tool. It allows to load heap dumps, and then runs a number of analyses on it and presents reports to see where all the memory is used.

I have no experience with JProfiler, but would expect it to be similar to YourKit. JProfiler seems to have a slightly larger market share than YourKit.

There is also the Java Flight Recorder (or Java Mission Control, as it is sometimes named), which is included since a few years with the JDK installation, but I was never really happy with it, likely due to missing IDE integration. The usage was just too cumbersome somehow for me.

Be aware that each Profiler will likely tell you another result, even when applied on the same code. Also, I think there was a presentation a while ago titled "why every java profiler lies" or similar, but I sadly can't find it right now. Basically, it boils down to that Sampling of Stack traces can only occur at certain places, which introduces a bias in the analysis, and that Tracing will disable a lot of optimizations the JVM usually could apply such that the measured results do no longer represent the same (machine) code that runs without profiling.

Further reading about profilers: https://zeroturnaround.com/rebellabs/top-5-java-profilers-revealed-real-world-data-with-visualvm-jprofiler-java-mission-control-yourkit-and-custom-tooling/ (2 years old, but still gives a good overview)


Re: Experiences with Java profilers?

by Dhirendra Singh on 2017-12-13 22:00:50

Yes, I've used visualVM too now for the last couple of years and find it pretty good for most profiling needs.


Re: Experiences with Java profilers?

by Michal Maciejewski on 2017-12-15 10:13:16

VisualVM, too (with some basic integration with Eclipse).

I used mostly 'sampling' when working on 100k AV fleets. Was helpful to point me to the part of the app that consumed most computation time, but not accurate enough to point me to the very bottleneck. Nevertheless, quite helpful despite those inaccuracies.

There is also 'profiling' in VisualVM, but then, as Marcel already said, you are profiling not exactly the same code you normally run, and it takes way longer.

Clone this wiki locally