Alex Rivera | Logout

Do Java programs ever crash?

Asked 2010-05-19T08:15:39.670
26

I am a c++ programmer , I know little bit about java. I know that java programmers do not have to work with memory directly like C++. I also know that most crashes in C++ appliations are due to memory corruptions.

So can an application written in Java crash due to a memory related issue?

Thanks

Edit
Report

2 Answers

2

Memory corruptions in C++ don't just happen. They're caused by software errors, like writing past the end of an array. Doing that will lead to a crash in Java as well. (No language will take source code that contains an error and produce a program that does what you intended originally.) The difference is that in C++ you get "undefined behavior", i.e. the program might crash somewhere else. The Java program will crash the moment you try to write past the end of the array, which makes it much easier to find the bug.

answered 2010-05-19T08:24:13.683
1

Of course they do crash :)

In addition to all the fine, answers, there's also the plain and simple JVM crash. For example, here's a question I asked concerning a case of a broken JVM which I can reliably crash using a particular data set (and it's not my fault: this "should not" happen... But it does ;)

I've seen server-side JVM crashes under some weird circumstances (Tomcat+Hibernate+Sun VM issue, back in the days, which were fixed, back in the days, by changing either Tomcat or the Sun VM).

I've seen JVM on the desktop side crashing when they should not (shipping commercial Java software to lots of desktop machine tend to rise the probability of you witnessing such a thing).

And the best I've seen is a JVM plain broken that I can reliably crash at work on several machines and, no, the machines ain't all having issues, they are rock-stable-solid workstations (since that post, I've tried on several machines and I can reproduce it):

Java VM: reproducable SIGSEGV on both 1.6.0_17 and 1.6.0_18, how to report?

(note that there a lot of other JVM that are fine on the same machines, with the same software/dataset).

The first thing I do when witnessing a JVM crash is change one of the software component: typically upgrading the JVM to the latest version.

answered 2010-05-19T15:28:22.597

Your Answer