Interviewer: What can cause a process to exit JAVA?

Interviewer: What can cause a process to exit JAVA?

introduction

On the occasion of the Tanabata festival, gave up countless sister paper of the offer, sitting in front of computer code word, is to bring new knowledge to the reader, this is a great cause!

Well, the reality is that nobody about. In order to resolve the embarrassment, I decided to write articles hard, ah, I must be too Cock wire!

Well, the focus began to say. Today, we are talking about this issue

JAVA process may disappear What are the reasons?

This issue is also an interview that often appear, as shown below

Interviewer: What can cause a process to exit JAVA?

ps: Since more than two years did not write crud, so forget mybatis how to use, so that the above issues, I chose to ignore.

Then we open an article that this question is actually very easy and nothing less than the three cases.

the linux OOM killer kill
JVM's own fault
jvm the OOM Process exited (very rare, I still never met)
Introduction

the linux OOM killer

The Linux kernel has a mechanism called OOM killer (Out-Of-Memory killer), this mechanism will monitor those who take up too much memory, especially in the moment quickly consume large amounts of memory processes, in order to prevent out of memory and the kernel will kill the process out.

So, you find that java process suddenly gone, was the first to suspect that is not the linux OOM killer to get rid of!

You can go to the following document translation

The system error log: / var / log / messages

You execute the command

egrep -i 'killed process' /var/log/messages

To log in to search.

Of course, you can also go inside the kernel log queries. Sometimes Linux system running on the system or java or other processes, some strange problems occur, such as suddenly hung up, such as a sudden reboot and so on. Can not find the problem in the software, then we should suspect the problem is hardware or kernel, then we can use dmesg to see:

dmesg | grep java

Output follows

[5673702.665338] Out of memory: Kill process 29953 (java) score 431 or sacrifice child
[5673702.665338] Killed process 29953, UID 500, (java) total-vm:9805316kB, anon-rss:2344496kB, file-rss:128kB

All these can be seen on the progress made on the operation of the kernel.

JVM's own fault

When the JVM error occurs that causes a fatal crash, will generate a hs_err_pid_xxx.log this file, which contains important information about the cause JVM crash, we can analyze the file to locate the cause of the JVM Crash to repair to ensure system stability.

By default, this file is generated in the working directory, of course, can also be specified by the Path JVM parameters:

-XX:ErrorFile=/var/log/hs_err_pid<pid>.log

The main contents of this file has the following contents

Log header
led to the crash thread information
for all the threads of information
security lock information point and
heap information
local code cache
compiler event
gc records
jvm memory mapping
jvm startup parameter
server information
after you get this file, needless to say, slowly eating it. Here, I want to feeling conscience he said. This file is a huge complex, if you will read this file, doing something.

JVM's OOM

Frankly, I rarely come across the situation because the JVM OOM, resulting in java process to exit.

Because, in general, appear OOM abnormal, JVM's GC will be recovered, it will not cause the JVM process to exit. To really say the only situation leads to quit, and that is a memory leak, because the memory footprint is growing, results. . . .

But this anomaly caused by the JVM OOM good investigation.

Because, you pay attention to two parameters

-XX: + HeapDumpOnOutOfMemoryError
-XX: HeapDumpPath = * / java.hprof;
then go to the corresponding directory to find the dump snapshot file, then this means VisualVM analysis visualization tools on the line. It is easy to locate the problem.

to sum up

In summary, the correct answer yes. First turn the file dump, dump if not, turn hs_err_pid.log log. If not, turn the kernel log.

Guess you like

Origin blog.51cto.com/14456091/2429298