| 2142 | } |
| 2143 | |
| 2144 | MemPool::~MemPool(void) |
| 2145 | { |
| 2146 | pool_destroying = true; |
| 2147 | |
| 2148 | decrement_usage(used_memory.value()); |
| 2149 | decrement_mapping(mapped_memory.value()); |
| 2150 | |
| 2151 | #ifdef USE_VALGRIND |
| 2152 | VALGRIND_DESTROY_MEMPOOL(this); |
| 2153 | |
| 2154 | for (size_t i = 0; i < delayedFreeCount; i++) |
| 2155 | delayedFree[i]->valgrindInternal(); |
| 2156 | #endif |
| 2157 | |
| 2158 | // release big objects |
| 2159 | while (bigHunks) |
| 2160 | { |
| 2161 | MemBigHunk* hunk = bigHunks; |
| 2162 | bigHunks = hunk->next; |
| 2163 | releaseRaw(pool_destroying, hunk, hunk->length, extentsCache); |
| 2164 | } |
| 2165 | |
| 2166 | if (parent) |
| 2167 | { |
| 2168 | // release blocks redirected to parent |
| 2169 | #ifdef VALIDATE_POOL |
| 2170 | MutexLockGuard guard(parent->mutex, FB_FUNCTION); |
| 2171 | #endif |
| 2172 | while (parentRedirected.getCount()) |
| 2173 | { |
| 2174 | MemBlock* block = parentRedirected.pop(); |
| 2175 | block->resetRedirect(parent); |
| 2176 | parent->releaseBlock(block, false); |
| 2177 | } |
| 2178 | } |
| 2179 | |
| 2180 | #ifdef MEM_DEBUG |
| 2181 | if (parent) |
| 2182 | { |
| 2183 | MutexLockGuard unlinkGuard(parent->mutex, FB_FUNCTION); |
| 2184 | bool flag = false; |
| 2185 | for (MemPool** pp = &(parent->child); *pp; pp = &((*pp)->next)) |
| 2186 | { |
| 2187 | if (*pp == this) |
| 2188 | { |
| 2189 | *pp = (*pp)->next; |
| 2190 | flag = true; |
| 2191 | break; |
| 2192 | } |
| 2193 | } |
| 2194 | fb_assert(flag); |
| 2195 | } |
| 2196 | #endif |
| 2197 | } |
| 2198 | |
| 2199 | template <class Extent> |
| 2200 | void MemPool::newExtent(size_t& size, Extent** linkedList) |
no test coverage detected