azagrebin commented on a change in pull request #11408: 
[FLINK-15989][FLINK-16225] Improve direct and metaspace out-of-memory error 
handling
URL: https://github.com/apache/flink/pull/11408#discussion_r393874481
 
 

 ##########
 File path: flink-core/src/main/java/org/apache/flink/util/ExceptionUtils.java
 ##########
 @@ -109,6 +131,26 @@ public static boolean 
isJvmFatalOrOutOfMemoryError(Throwable t) {
                return isJvmFatalError(t) || t instanceof OutOfMemoryError;
        }
 
+       /**
+        * Checks whether the given exception indicates a JVM metaspace 
out-of-memory error.
+        *
+        * @param t The exception to check.
+        * @return True, if the exception is the metaspace {@link 
OutOfMemoryError}, false otherwise.
+        */
+       public static boolean isMetaspaceOutOfMemoryError(Throwable t) {
+               return t instanceof OutOfMemoryError && 
t.getMessage().startsWith("Metaspace");
+       }
 
 Review comment:
   Good question.
   I have not found any other ways to do it using some Java API.
   The message is documented though, e.g. in Oracle Java 
[8](https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/memleaks002.html)
 and 
[11](https://docs.oracle.com/en/java/javase/11/troubleshoot/troubleshoot-memory-leaks.html#GUID-19F6D28E-75A1-4480-9879-D0932B2F305B).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to