mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
...
This commit is contained in:
parent
e1d75a0d85
commit
de0db63bca
@ -124,6 +124,8 @@ struct DoubleLinkedList{
|
|||||||
template<int __BlockSize=128>
|
template<int __BlockSize=128>
|
||||||
struct MemoryPool{
|
struct MemoryPool{
|
||||||
static const size_t __MaxBlocks = 256*1024 / __BlockSize;
|
static const size_t __MaxBlocks = 256*1024 / __BlockSize;
|
||||||
|
static const size_t __MinArenaCount = PK_GC_MIN_THRESHOLD*100 / (256*1024);
|
||||||
|
|
||||||
struct Block{
|
struct Block{
|
||||||
void* arena;
|
void* arena;
|
||||||
char data[__BlockSize];
|
char data[__BlockSize];
|
||||||
@ -224,6 +226,7 @@ struct MemoryPool{
|
|||||||
|
|
||||||
void shrink_to_fit(){
|
void shrink_to_fit(){
|
||||||
PK_GLOBAL_SCOPE_LOCK();
|
PK_GLOBAL_SCOPE_LOCK();
|
||||||
|
if(_arenas.size() < __MinArenaCount) return;
|
||||||
_arenas.apply([this](Arena* arena){
|
_arenas.apply([this](Arena* arena){
|
||||||
if(arena->full()){
|
if(arena->full()){
|
||||||
_arenas.erase(arena);
|
_arenas.erase(arena);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user