You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2016/07/18 22:08:02 UTC

arrow git commit: ARROW-238: Change InternalMemoryPool::Free() to return Status::Invalid when ther…

Repository: arrow
Updated Branches:
  refs/heads/master 62390d842 -> 55bfa8343


ARROW-238: Change InternalMemoryPool::Free() to return Status::Invalid when ther\u2026

\u2026e is insufficient memory.

Author: Jihoon Son <ji...@apache.org>

Closes #102 from jihoonson/ARROW-238 and squashes the following commits:

cb9e7b1 [Jihoon Son] Disable FreeLargeMemory test for release builds
f903130 [Jihoon Son] Free allocated memory after death
0077a70 [Jihoon Son] Adjust the amount of memory allocation
b1af59b [Jihoon Son] Change to ASSERT_EXIT
b4159f0 [Jihoon Son] Reflect comments
e89a1f9 [Jihoon Son] Change python implementation as well.
7651570 [Jihoon Son] Change InternalMemoryPool::Free() to return Status::Invalid when there is insufficient memory.


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

Branch: refs/heads/master
Commit: 55bfa834312685991d615301ac0b4fcc7c11640b
Parents: 62390d8
Author: Jihoon Son <ji...@apache.org>
Authored: Mon Jul 18 15:07:48 2016 -0700
Committer: Wes McKinney <we...@apache.org>
Committed: Mon Jul 18 15:07:48 2016 -0700

----------------------------------------------------------------------
 cpp/src/arrow/util/logging.h           |  2 +-
 cpp/src/arrow/util/memory-pool-test.cc | 14 ++++++++++++++
 cpp/src/arrow/util/memory-pool.cc      |  2 ++
 3 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/55bfa834/cpp/src/arrow/util/logging.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/logging.h b/cpp/src/arrow/util/logging.h
index fccc5e3..54f6759 100644
--- a/cpp/src/arrow/util/logging.h
+++ b/cpp/src/arrow/util/logging.h
@@ -40,7 +40,7 @@ namespace arrow {
 
 #define ARROW_CHECK(condition)                               \
   (condition) ? 0 : ::arrow::internal::FatalLog(ARROW_FATAL) \
-                        << __FILE__ << __LINE__ << "Check failed: " #condition " "
+                        << __FILE__ << __LINE__ << " Check failed: " #condition " "
 
 #ifdef NDEBUG
 #define ARROW_DFATAL ARROW_WARNING

http://git-wip-us.apache.org/repos/asf/arrow/blob/55bfa834/cpp/src/arrow/util/memory-pool-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/memory-pool-test.cc b/cpp/src/arrow/util/memory-pool-test.cc
index 8e7dfd6..919f374 100644
--- a/cpp/src/arrow/util/memory-pool-test.cc
+++ b/cpp/src/arrow/util/memory-pool-test.cc
@@ -46,4 +46,18 @@ TEST(DefaultMemoryPool, OOM) {
   ASSERT_RAISES(OutOfMemory, pool->Allocate(to_alloc, &data));
 }
 
+TEST(DefaultMemoryPoolDeathTest, FreeLargeMemory) {
+  MemoryPool* pool = default_memory_pool();
+
+  uint8_t* data;
+  ASSERT_OK(pool->Allocate(100, &data));
+
+#ifndef NDEBUG
+  EXPECT_EXIT(pool->Free(data, 120), ::testing::ExitedWithCode(1),
+               ".*Check failed: \\(bytes_allocated_\\) >= \\(size\\)");
+#endif
+
+  pool->Free(data, 100);
+}
+
 }  // namespace arrow

http://git-wip-us.apache.org/repos/asf/arrow/blob/55bfa834/cpp/src/arrow/util/memory-pool.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/memory-pool.cc b/cpp/src/arrow/util/memory-pool.cc
index 0a58e5a..fed149b 100644
--- a/cpp/src/arrow/util/memory-pool.cc
+++ b/cpp/src/arrow/util/memory-pool.cc
@@ -23,6 +23,7 @@
 #include <sstream>
 
 #include "arrow/util/status.h"
+#include "arrow/util/logging.h"
 
 namespace arrow {
 
@@ -81,6 +82,7 @@ int64_t InternalMemoryPool::bytes_allocated() const {
 
 void InternalMemoryPool::Free(uint8_t* buffer, int64_t size) {
   std::lock_guard<std::mutex> guard(pool_lock_);
+  DCHECK_GE(bytes_allocated_, size);
   std::free(buffer);
   bytes_allocated_ -= size;
 }