下面列出了怎么用io.netty.util.internal.OutOfDirectMemoryError的API类实例代码及写法,或者点击链接到github查看源代码。
public static boolean isDirectMemoryOOM(Throwable e) {
if (e instanceof OutOfDirectMemoryError || e instanceof OutOfMemoryException) {
// These are always direct memory errors
return true;
}
return (e instanceof OutOfMemoryError) && DIRECT_MEMORY_OOM_MESSAGE.equals(e.getMessage());
}
private OutOfDirectMemoryError newOutOfDirectMemoryError(String message) throws IllegalAccessException, InvocationTargetException, InstantiationException {
// OutOfDirectMemoryError has a package-private constructor.
// Use reflection to instantiate it for testing purposes.
Constructor<OutOfDirectMemoryError> constructor = null;
try {
constructor = OutOfDirectMemoryError.class.getDeclaredConstructor(String.class);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
constructor.setAccessible(true);
return constructor.newInstance(message);
}