ArrayList$Itr and Escape Analysis

Can somebody settle this once and for all…

JVisualVM reports that I’m generating megabytes worth of iterators every frame. This is bothering because there are other things I’d rather have room to create megabytes of every frame. However I’ve heard anecdotally that it is only the presence of JVisualVM’s profiling that actually causes these iterators to be picked up because it turns off the escape analysis feature in the JVM.

Could the assembled hive mind prove one way or the other that this is indeed happening (who’s got a debug VM handy to print the assembly out)?

Cas :slight_smile:

(For your reference: my knowledge on the subject comes from this article but it is four years old and things change)

Cas :slight_smile:

You don’t need a debug VM, just the disasm DLL (which Oracle can’t distribute). I posted a link at some point, but am unable to find it with a search (and don’t have a copy ATM)

EDIT: Oh the file is ‘hsdis-amd64.dll’ and probably someone has a copy.

Are you in a position to try / use Java Mission Control? According to various things I’ve read, including the article you linked to, this can analyse without switching off escape analysis.

Stop wasting your time with traditional profilers. Treat them like antivirus software; they lie all the time and they are not made to help you. Yes, they’re that bad.

This is true, merely the presence of an attached profiler will disable escape analysis and many other optimizations. The simplest way to identify whether EA is kicking in or not is to use JITWatch. It’s my favorite performance analysis tool these days. It doesn’t require a debug VM or the disasm DLL (though disasm is highly recommended for low-level tuning). Here’s a demo of the EA reporting:

LK1Ain1JDlQ

A debug VM will tell you why a particular allocation has not been eliminated. This is useful, but not critical for performance tuning, assuming you’re familiar with the basics. Once you identify a problematic allocation, it takes a bit of refactoring to solve the problem and it’s rarely an unfixable situation. Like everything else in Java, bytecode size, call depth and associated inlining decisions play the most critical role.

JITWatch! Of course. I knew there was a tool I was missing but I just couldn’t remember what it was. Thanks Spasi.

I’ve used Oracle’s Mission Control thing and sure enough it’s quite different in output to JVisualVM.

Cas :slight_smile: