From 6590c2817428493828bb674323dd31b95dcdf922 Mon Sep 17 00:00:00 2001 From: alexpeshkoff Date: Fri, 9 Oct 2015 11:45:08 +0000 Subject: [PATCH] Added memory pool describing constant MAX_MEDUIM_BLOCK_SIZE --- src/common/classes/alloc.h | 3 +++ src/common/classes/misc/class_test.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/common/classes/alloc.h b/src/common/classes/alloc.h index 9276f5a9fa..4d7aaa0b1f 100644 --- a/src/common/classes/alloc.h +++ b/src/common/classes/alloc.h @@ -165,6 +165,9 @@ private: static MemoryStats* default_stats_group; public: + // This is maximum block size which is cached (not allocated directly from OS) + enum RecommendedBufferSize { MAX_MEDUIM_BLOCK_SIZE = 64384 }; // MediumLimits::TOP_LIMIT - 128 + static MemoryPool* defaultMemoryManager; public: diff --git a/src/common/classes/misc/class_test.cpp b/src/common/classes/misc/class_test.cpp index 14359f5658..89a6bb0f56 100644 --- a/src/common/classes/misc/class_test.cpp +++ b/src/common/classes/misc/class_test.cpp @@ -579,6 +579,12 @@ void testAllocator() VERIFY_POOL(pool); VERIFY_POOL(parent); + printf("Allocate max recommended medium buffer (%d bytes): ", MemoryPool::MAX_MEDUIM_BLOCK_SIZE); + void* maxMedium = pool->allocate(MemoryPool::MAX_MEDUIM_BLOCK_SIZE); + 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); @@ -593,6 +599,12 @@ void testAllocator() } while (bigItems.getNext()); printf(" DONE\n"); + printf("Deallocate max recommended medium buffer: "); + pool->deallocate(maxMedium); + printf(" DONE\n"); + VERIFY_POOL(pool); + VERIFY_POOL(parent); + printf("Deallocate %d large items: ", LARGE_ITEMS/2); for (i = 0; ideallocate(la[i]);