TODO: remove this test when remove deprecatedAddDefaultLeafMemoryPool.
| 366 | options.alignment = alignment; |
| 367 | MemoryManager manager{options}; |
| 368 | ASSERT_EQ(manager.numPools(), 3); |
| 369 | const int numPools = 100; |
| 370 | std::vector<std::shared_ptr<MemoryPool>> userRootPools; |
| 371 | std::vector<std::shared_ptr<MemoryPool>> userLeafPools; |
| 372 | for (int i = 0; i < numPools; ++i) { |
| 373 | const std::string name(std::to_string(i)); |
| 374 | auto pool = i % 2 ? manager.addLeafPool(name) : manager.addRootPool(name); |
| 375 | ASSERT_EQ(pool->name(), name); |
| 376 | if (i % 2) { |
| 377 | ASSERT_EQ(pool->kind(), MemoryPool::Kind::kLeaf); |
| 378 | userLeafPools.push_back(pool); |
| 379 | ASSERT_EQ(pool->parent()->name(), manager.deprecatedSysRootPool().name()); |
| 380 | } else { |
| 381 | ASSERT_EQ(pool->kind(), MemoryPool::Kind::kAggregate); |
| 382 | ASSERT_EQ(pool->parent(), nullptr); |
| 383 | userRootPools.push_back(pool); |
| 384 | } |
| 385 | } |
| 386 | auto leafUnamedPool = manager.addLeafPool(); |
| 387 | ASSERT_FALSE(leafUnamedPool->name().empty()); |
| 388 | ASSERT_EQ(leafUnamedPool->kind(), MemoryPool::Kind::kLeaf); |
| 389 | auto rootUnamedPool = manager.addRootPool(); |
| 390 | ASSERT_FALSE(rootUnamedPool->name().empty()); |
| 391 | ASSERT_EQ(rootUnamedPool->kind(), MemoryPool::Kind::kAggregate); |
| 392 | ASSERT_EQ(rootUnamedPool->parent(), nullptr); |
| 393 | ASSERT_EQ(manager.numPools(), 1 + numPools + 3 + 1); |
| 394 | userLeafPools.clear(); |
| 395 | leafUnamedPool.reset(); |
| 396 | ASSERT_EQ(manager.numPools(), 1 + numPools / 2 + 1 + 1 + 1); |
| 397 | userRootPools.clear(); |
| 398 | ASSERT_EQ(manager.numPools(), 1 + 3); |
| 399 | rootUnamedPool.reset(); |
| 400 | ASSERT_EQ(manager.numPools(), 3); |
| 401 | } |
| 402 | |
| 403 | // TODO: when run sequentially, e.g. `buck run dwio/memory/...`, this has side |
| 404 | // effects for other tests using process singleton memory manager. Might need to |
| 405 | // use folly::Singleton for isolation by tag. |
| 406 | TEST_F(MemoryManagerTest, globalMemoryManager) { |
nothing calls this directly
no test coverage detected