本文整理汇总了C++中MemoryPool::print_contents方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryPool::print_contents方法的具体用法?C++ MemoryPool::print_contents怎么用?C++ MemoryPool::print_contents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryPool
的用法示例。
在下文中一共展示了MemoryPool::print_contents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testAllocator
void testAllocator()
{
printf("Test Firebird::MemoryPool\n");
MemoryPool* parent = getDefaultMemoryPool();
MemoryPool* pool = MemoryPool::createPool(parent);
MallocAllocator allocator;
BePlusTree<AllocItem, AllocItem, MallocAllocator, DefaultKeyValue<AllocItem>, AllocItem> items(&allocator),
bigItems(&allocator);
Vector<void*, LARGE_ITEMS> la;
printf("Allocate %d large items: ", LARGE_ITEMS);
int i;
for (i = 0; i<LARGE_ITEMS; i++) {
la.add(pool->allocate(LARGE_ITEM_SIZE));
VERIFY_POOL(pool);
}
VERIFY_POOL(pool);
printf(" DONE\n");
printf("Allocate %d items: ", ALLOC_ITEMS);
int n = 0;
VERIFY_POOL(pool);
for (i = 0; i < ALLOC_ITEMS; i++) {
n = n * 47163 - 57412;
// n = n * 45578 - 17651;
AllocItem temp = {n, pool->allocate((n % MAX_ITEM_SIZE + MAX_ITEM_SIZE) / 2 + 1)};
items.add(temp);
}
printf(" DONE\n");
VERIFY_POOL(pool);
VERIFY_POOL(parent);
printf("Deallocate half of items in quasi-random order: ");
n = 0;
if (items.getFirst()) do {
pool->deallocate(items.current().item);
n++;
} while (n < ALLOC_ITEMS / 2 && items.getNext());
printf(" DONE\n");
VERIFY_POOL(pool);
VERIFY_POOL(parent);
printf("Allocate %d big items: ", BIG_ITEMS);
n = 0;
VERIFY_POOL(pool);
for (i = 0; i < BIG_ITEMS; i++) {
n = n * 47163 - 57412;
// n = n * 45578 - 17651;
AllocItem temp = {n, pool->allocate((n % BIG_SIZE + BIG_SIZE) / 2 + 1)};
bigItems.add(temp);
}
printf(" DONE\n");
VERIFY_POOL(pool);
VERIFY_POOL(parent);
printf("Deallocate the rest of small items in quasi-random order: ");
while (items.getNext()) {
pool->deallocate(items.current().item);
}
printf(" DONE\n");
VERIFY_POOL(pool);
VERIFY_POOL(parent);
printf("Deallocate big items in quasi-random order: ");
if (bigItems.getFirst()) do {
pool->deallocate(bigItems.current().item);
} while (bigItems.getNext());
printf(" DONE\n");
printf("Deallocate %d large items: ", LARGE_ITEMS/2);
for (i = 0; i<LARGE_ITEMS/2; i++)
pool->deallocate(la[i]);
VERIFY_POOL(pool);
printf(" DONE\n");
// pool->verify_pool();
// parent->verify_pool();
pool->print_contents(stdout, false);
parent->print_contents(stdout, false);
MemoryPool::deletePool(pool);
// parent->verify_pool();
// TODO:
// Test critically low memory conditions
// Test that tree correctly recovers in low-memory conditions
}