arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adene...@apache.org
Subject arrow git commit: ARROW-1084: Implementations of BufferAllocator should handle Netty's OutOfDirectMemoryError
Date Fri, 02 Jun 2017 19:32:40 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 092afb6dc -> ba97f343f


ARROW-1084: Implementations of BufferAllocator should handle Netty's OutOfDirectMemoryError


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/ba97f343
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/ba97f343
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/ba97f343

Branch: refs/heads/master
Commit: ba97f343f631138a51a1c337eebba83e03add454
Parents: 092afb6
Author: adeneche <adeneche@dremio.com>
Authored: Fri Jun 2 10:22:52 2017 -0700
Committer: adeneche <adeneche@dremio.com>
Committed: Fri Jun 2 12:25:34 2017 -0700

----------------------------------------------------------------------
 .../java/org/apache/arrow/memory/BaseAllocator.java   | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/ba97f343/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java
----------------------------------------------------------------------
diff --git a/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java b/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java
index aaa7ce8..ddc78f0 100644
--- a/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java
+++ b/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java
@@ -22,6 +22,7 @@ import com.google.common.base.Preconditions;
 
 import io.netty.buffer.ArrowBuf;
 import io.netty.buffer.UnsafeDirectLittleEndian;
+import io.netty.util.internal.OutOfDirectMemoryError;
 
 import org.apache.arrow.memory.AllocationManager.BufferLedger;
 import org.apache.arrow.memory.util.AssertionUtil;
@@ -266,7 +267,18 @@ public abstract class BaseAllocator extends Accountant implements BufferAllocato
       success = true;
       listener.onAllocation(actualRequestSize);
       return buffer;
-    } finally {
+    } catch (OutOfMemoryError e) {
+      /*
+       * OutOfDirectMemoryError is thrown by Netty when we exceed the direct memory limit
defined by -XX:MaxDirectMemorySize.
+       * OutOfMemoryError with "Direct buffer memory" message is thrown by java.nio.Bits
when we exceed the direct memory limit.
+       *   This should never be hit in practice as Netty is expected to throw an OutOfDirectMemoryError
first.
+       */
+      if (e instanceof OutOfDirectMemoryError || "Direct buffer memory".equals(e.getMessage()))
{
+        throw new OutOfMemoryException(e);
+      }
+      throw e;
+    }
+    finally {
       if (!success) {
         releaseBytes(actualRequestSize);
       }


Mime
View raw message