diff options
| author | Angus Gratton <angus@redyak.com.au> | 2023-09-05 10:58:19 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-09-15 12:19:13 +1000 |
| commit | 3e8aed9fcce9068f40780b23148feaa1e041a18a (patch) | |
| tree | 9771d7460caf22d8ec28c53e7c2560ff0445dfb4 /py/modgc.c | |
| parent | 174bb28d8e27c7b082d2c8d7b18f7bf2cdf2c62e (diff) | |
py/gc: Add "max new split" value in result of gc.mem_free().
Follow-up to 519c24dd487 when MICROPY_GC_SPLIT_HEAP_AUTO is enabled, based
on discussion at
https://github.com/orgs/micropython/discussions/12316#discussioncomment-6858007
gc.mem_free() is always a heuristic, but this makes it a more useful
heuristic for common use cases.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Diffstat (limited to 'py/modgc.c')
| -rw-r--r-- | py/modgc.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/py/modgc.c b/py/modgc.c index c11bcaecd..7b18045b0 100644 --- a/py/modgc.c +++ b/py/modgc.c @@ -64,7 +64,12 @@ MP_DEFINE_CONST_FUN_OBJ_0(gc_isenabled_obj, gc_isenabled); STATIC mp_obj_t gc_mem_free(void) { gc_info_t info; gc_info(&info); + #if MICROPY_GC_SPLIT_HEAP_AUTO + // Include max_new_split value here as a more useful heuristic + return MP_OBJ_NEW_SMALL_INT(info.free + info.max_new_split); + #else return MP_OBJ_NEW_SMALL_INT(info.free); + #endif } MP_DEFINE_CONST_FUN_OBJ_0(gc_mem_free_obj, gc_mem_free); |
