Prevent program from crashing when showing allocation stack traces
Asked Answered
S

1

10

Question

Why does VisualVM terminate my program when attempting to view object allocation stack trace, and how do I fix it?


I'm cleaning up an application which has a few memory problems, the biggest being creating a bunch of short-lived int[] which causes GC to fire like crazy:

enter image description here

When I right click int[] and choose Take Snapshot and Show Allocation Stack Traces, my application closes and a warning box pops up saying Failed to obtain results snapshot. The application terminated:

enter image description here

The closest thing I found on the subject was a bug report which recommended running my profiled application with -Xnoclassgc. It didn't work, the results were the same.


Specs

VisualVM: 1.8.0_60 (Build 1380-140910); platform 20140910-unknown-revn
Java: 1.8.0_60; Java HotSpot(TM) 64-Bit Server VM (25.60-b23, mixed mode)
Eclipse: Luna Release (4.4.0) Build id: 20140612-0600
System: Windows 7 (6.1) Service Pack 1, amd64 64bit

Crash log

http://pastebin.com/a4YPWutj

The size of the crash log exceeded the character limit, so I had to place it elsewhere. Sorry.

Soche answered 2/12, 2015 at 21:5 Comment(8)
Just a few questions first: 1. Is Eclipse anyhow related to this situation you just described? You listed your Eclipse version, but did not mention it any other way. 2. Did the Java and System info come from the server you are running the application on?Solange
Also the application crash should result in a crash report saved for debugging purposes. Can you locate the file (hprof?) and paste the relevant content here?Solange
Do you test Java Mission Control (jmc.exe) ? It's the same tool but for Java8 with some none free feature. But you can do the same than VisualVM.Garibald
@GergelyBasco It's the IDE the program was launched from, not sure if that may play a role. I am using the stand-alone VisualVM though, not the plugin. And yes, those are the specs for the machine the profiled application was running on. I cannot seem to find any heap dump file, I will reproduce the problem and see if one generates. I'll also upload a picture of the error box that pops up, which is simply just a message and nothing else /:Soche
@Garibald I've used it to monitor data before, but am not familiar with it. I will attempt to use it's flight recorder to see if I can close in on the memory problem, but I'd very much like to know the problem behind the VisualVM error and how one would fix it in-case this problems occurs in an environment where only VisualVM is present/supportedSoche
This is the JVM param you need to set to define a specific location for the crashfile: -XX:ErrorFile=/var/log/java/hs_err_pid%p.log. Just make sure that you add this to the app, not to Eclipse.Solange
@GergelyBacso I have added the crash logSoche
App crashing on this is not expected. Did you try updating to newer versions of Java and Visual VM?Jitney
S
7

Ok. So based on the crashlog obtained, it looks like you ran into a VisualVM bug already reported here:

JVM being profiled crashes

The submitter of the original bug narrowed this behavior down to Java8, so the best chance you have is running a VisualVM on an older (Java7) runtime. If this is an option for you, then you only need to download a Java7 JDK and run the VisualVM directly from there.

Solange answered 12/12, 2015 at 14:11 Comment(1)
Aw man, I guess I could start using JMC for now, as using Java 7 is not an option /: Thanks for finding this though!Soche

© 2022 - 2024 — McMap. All rights reserved.