mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
Update memory.cpp
This commit is contained in:
parent
736df8ad31
commit
fbd825951c
@ -238,14 +238,11 @@ struct MemoryPool{
|
||||
std::string info(){
|
||||
int n_used_arenas = _arenas.size();
|
||||
int n_total_arenas = n_used_arenas + _empty_arenas.size();
|
||||
int n_used_blocks = 0;
|
||||
int n_total_blocks = n_total_arenas * __MaxBlocks;
|
||||
size_t allocated_size = 0;
|
||||
size_t total_size = 0;
|
||||
_arenas.apply([&](Arena* arena){
|
||||
allocated_size += arena->allocated_size();
|
||||
total_size += __BlockSize * __MaxBlocks;
|
||||
n_used_blocks += __MaxBlocks - arena->_free_list_size;
|
||||
});
|
||||
_empty_arenas.apply([&](Arena* arena){
|
||||
total_size += __BlockSize * __MaxBlocks;
|
||||
@ -254,14 +251,12 @@ struct MemoryPool{
|
||||
snprintf(
|
||||
buffer,
|
||||
sizeof(buffer),
|
||||
"MemoryPool<%d>: %.2f/%.2f MB - %d/%d arenas - %d/%d blocks",
|
||||
"pool%d: %.2f/%.2f MB - %d/%d arenas",
|
||||
__BlockSize,
|
||||
(float)allocated_size / (1024*1024),
|
||||
(float)total_size / (1024*1024),
|
||||
n_used_arenas,
|
||||
n_total_arenas,
|
||||
n_used_blocks,
|
||||
n_total_blocks
|
||||
n_total_arenas
|
||||
);
|
||||
return buffer;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user