Error handling (e.g. OutOfMemoryError) on servers

What is the best practice when dealing with errors in a server application?

In particular, how do you think the application should handle errors like OutOfMemoryError?

I am particularly interested in Java applications running in Tomcat, but I think this is a more general problem.


The reason I ask is because I am browsing a web application that often issues OOME, but usually it just logs them and then continues to execute. This obviously leads to more OOME.

Although this is certainly a bad practice, in my opinion, I'm not quite sure that stopping the server would be the best solution.

+3
source share
9 answers

There is not much to fix OutOfMemoryError, except how to clear the code and configure the JVM memory (but if you have a leak somewhere it's just a gang)

If you do not have access to the source code and / or you do not want to fix it, the external solution should be to use some kind of watchdog program that will monitor the Java application and automatically restart it when OOME is detected. Here is a link to one of these programs .

Of course, it is assumed that the application will restart.

+2
source

The application should not handle OOM at all - it should be the responsibility of the server.

: . , ; , .:)

+2

, OOME, ( ). - ( -) - ( , - ), . , , , , , , , - . , Tomcat , . , , .

+1

An OutOfMemoryError - , - .

, , , , , - - , .

, , , , - (, , - ). - , - , .

+1

@Michael Borgwardt, OutOfMemoryError Java. , OutOfMemoryError .

+1

, , OOM, OOM, - . OOM . , , ,

+1

, .

, , :

  • .
  • , , , , . , .
0

javadoc java.lang.Error:

An Error Throwable, , . . ThreadDeath, "" , Error, .

throws Error, , , , .

, Error , , , "" . , .

OutOfMemoryError, , , (, ), JVM , , - .. , , .

0

, OutOfMemoryError.

, . , - . , , OutOfMemoryError. , OutOfMemoryError. , , , .

, Tomcat - , . error-page, , .

0

Source: https://habr.com/ru/post/1718450/


All Articles