1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 04:34:59 +00:00
serenity/Userland/Libraries/LibJS/Heap/BlockAllocator.h
Andreas Kling 17f239e1c0 LibJS: Increase GC heap BlockAllocator cache size
Let's accept keeping up to 8 MiB of HeapBlock memory cached. This allows
the GC allocator to reuse memory instead of asking the kernel for more.
2021-10-08 00:35:29 +02:00

28 lines
465 B
C++

/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Vector.h>
#include <LibJS/Forward.h>
namespace JS {
class BlockAllocator {
public:
BlockAllocator();
~BlockAllocator();
void* allocate_block(char const* name);
void deallocate_block(void*);
private:
static constexpr size_t max_cached_blocks = 512;
Vector<void*, max_cached_blocks> m_blocks;
};
}