summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/gc.c14
-rw-r--r--py/gc.h1
2 files changed, 12 insertions, 3 deletions
diff --git a/py/gc.c b/py/gc.c
index 2cc64f3620..1c1865cdb4 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -324,15 +324,17 @@ void gc_info(gc_info_t *info) {
info->total = MP_STATE_MEM(gc_pool_end) - MP_STATE_MEM(gc_pool_start);
info->used = 0;
info->free = 0;
+ info->max_free = 0;
info->num_1block = 0;
info->num_2block = 0;
info->max_block = 0;
bool finish = false;
- for (size_t block = 0, len = 0; !finish;) {
+ for (size_t block = 0, len = 0, len_free = 0; !finish;) {
size_t kind = ATB_GET_KIND(block);
switch (kind) {
case AT_FREE:
info->free += 1;
+ len_free += 1;
len = 0;
break;
@@ -367,6 +369,12 @@ void gc_info(gc_info_t *info) {
if (len > info->max_block) {
info->max_block = len;
}
+ if (finish || kind == AT_HEAD) {
+ if (len_free > info->max_free) {
+ info->max_free = len_free;
+ }
+ len_free = 0;
+ }
}
}
@@ -726,8 +734,8 @@ void gc_dump_info(void) {
gc_info(&info);
mp_printf(&mp_plat_print, "GC: total: %u, used: %u, free: %u\n",
(uint)info.total, (uint)info.used, (uint)info.free);
- mp_printf(&mp_plat_print, " No. of 1-blocks: %u, 2-blocks: %u, max blk sz: %u\n",
- (uint)info.num_1block, (uint)info.num_2block, (uint)info.max_block);
+ mp_printf(&mp_plat_print, " No. of 1-blocks: %u, 2-blocks: %u, max blk sz: %u, max free sz: %u\n",
+ (uint)info.num_1block, (uint)info.num_2block, (uint)info.max_block, (uint)info.max_free);
}
void gc_dump_alloc_table(void) {
diff --git a/py/gc.h b/py/gc.h
index e790c34ac0..7d8fe2bf8c 100644
--- a/py/gc.h
+++ b/py/gc.h
@@ -54,6 +54,7 @@ typedef struct _gc_info_t {
size_t total;
size_t used;
size_t free;
+ size_t max_free;
size_t num_1block;
size_t num_2block;
size_t max_block;