tillrohrmann commented on a change in pull request #11109:
[FLINK-15758][MemManager] Release segment and its unsafe memory in GC Cleaner
URL: https://github.com/apache/flink/pull/11109#discussion_r410255110
##########
File path:
flink-core/src/main/java/org/apache/flink/util/JavaGcCleanerWrapper.java
##########
@@ -254,5 +339,31 @@ public Runnable create(Object owner, Runnable
cleanupOperation) {
}
};
}
+
+ @Override
+ public boolean waitForGcToRunReadyCleaners() throws
InterruptedException {
+ Object javaLangRefAccess = getJavaLangRefAccess();
+ try {
+ return (Boolean)
waitForReferenceProcessingMethod.invoke(javaLangRefAccess);
+ } catch (IllegalAccessException |
InvocationTargetException e) {
+ if (e.getCause() instanceof
InterruptedException) {
+ //noinspection
ThrowInsideCatchBlockWhichIgnoresCaughtException
+ throw (InterruptedException)
e.getCause();
+ }
+ String message = "FATAL UNEXPECTED - Failed to
invoke JavaLangRefAccess#waitForReferenceProcessing";
+ LOG.error(message, e);
+ throw new Error(message, e);
+ }
+ }
+
+ private Object getJavaLangRefAccess() {
+ try {
+ return getJavaLangRefAccessMethod.invoke(null);
+ } catch (IllegalAccessException |
InvocationTargetException e) {
+ String message = "FATAL UNEXPECTED - Failed to
invoke SharedSecrets#getJavaLangRefAccess";
+ LOG.error(message, e);
+ throw new Error(message, e);
+ }
+ }
Review comment:
It looks to me as if these methods are more or less the same as the ones
used in `LegacyCleanerFactory`. I think we can introduce a single type which is
instantiated with the different `Methods` and then used for Java 9 and Java < 9.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services