forked from weaselab/conflict-set
Bound individual size of allocation to put in free list
This commit is contained in:
+4
-2
@@ -260,7 +260,8 @@ static_assert(sizeof(Node4) < kMinChildrenNode4 * kBytesPerKey);
|
||||
|
||||
// Bounds memory usage in free list, but does not account for memory for partial
|
||||
// keys.
|
||||
template <class T, int64_t kMemoryBound = (1 << 20)>
|
||||
template <class T, int64_t kMemoryBound = (1 << 20),
|
||||
int64_t kMaxIndividual = (1 << 10)>
|
||||
struct BoundedFreeListAllocator {
|
||||
static_assert(sizeof(T) >= sizeof(void *));
|
||||
static_assert(std::derived_from<T, Node>);
|
||||
@@ -296,7 +297,8 @@ struct BoundedFreeListAllocator {
|
||||
--liveAllocations;
|
||||
#endif
|
||||
static_assert(std::is_trivially_destructible_v<T>);
|
||||
if (freeListBytes >= kMemoryBound) {
|
||||
if (sizeof(T) + p->partialKeyCapacity > kMaxIndividual ||
|
||||
freeListBytes >= kMemoryBound) {
|
||||
return free(p);
|
||||
}
|
||||
memcpy((void *)p, &freeList, sizeof(freeList));
|
||||
|
||||
Reference in New Issue
Block a user