javaperformanceoptimizationjfrjava-mission-control

How to interpret lambda in memory view of Java Mission Control


I'm analysing part of a Java 8 application using Java Mission Control. I'm using Java Mission Control 6.0.0 (the version that comes with Java 9 and 10). In the Memory view, under Java Application I see the following:

Java Mission Control Memory View Screenshot

87M seems like a lot of memory for lambdas, especially when seen in the context of the memory being used elsewhere. How should I interpret and perhaps optimise this memory use for the lambdas?


Solution

  • You may want to take that number with a grain of salt, Flight Recorder samples memory allocations. I think it is misleading to show a total in bytes, since that kind of accuracy doesn't exist. A percentage that shows the "allocation pressure" would be better.

    You can use the table to get a rough idea of where most of the allocation occurs, at least if you have a few hundred samples. This is similar to Hot Methods table that shows which Java code the JVM executes the most, but not the number of milleseconds methods have been executing.

    If you want to remove unnecessary allocations, I would look at the stack trace and see if you could do something there.