| 35 | virtual ::arrow::MemoryPool* memory_pool() = 0; |
| 36 | |
| 37 | void TestMemoryTracking() { |
| 38 | auto pool = memory_pool(); |
| 39 | |
| 40 | uint8_t* data; |
| 41 | const auto old_bytes_allocated = pool->bytes_allocated(); |
| 42 | ASSERT_OK(pool->Allocate(100, &data)); |
| 43 | EXPECT_EQ(static_cast<uint64_t>(0), reinterpret_cast<uint64_t>(data) % 64); |
| 44 | ASSERT_EQ(old_bytes_allocated + 100, pool->bytes_allocated()); |
| 45 | |
| 46 | uint8_t* data2; |
| 47 | ASSERT_OK(pool->Allocate(27, &data2)); |
| 48 | EXPECT_EQ(static_cast<uint64_t>(0), reinterpret_cast<uint64_t>(data2) % 64); |
| 49 | ASSERT_EQ(old_bytes_allocated + 127, pool->bytes_allocated()); |
| 50 | |
| 51 | pool->Free(data, 100); |
| 52 | ASSERT_EQ(old_bytes_allocated + 27, pool->bytes_allocated()); |
| 53 | pool->Free(data2, 27); |
| 54 | ASSERT_EQ(old_bytes_allocated, pool->bytes_allocated()); |
| 55 | } |
| 56 | |
| 57 | void TestOOM() { |
| 58 | auto pool = memory_pool(); |
no test coverage detected