File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -481,7 +481,15 @@ void *gc_alloc(size_t n_bytes, unsigned int alloc_flags) {
481481 #if MICROPY_GC_ALLOC_THRESHOLD
482482 if (!collected && MP_STATE_MEM (gc_alloc_amount ) >= MP_STATE_MEM (gc_alloc_threshold )) {
483483 GC_EXIT ();
484+ #if MICROPY_GC_LOG
485+ gc_dump_info ();
486+ printf ("GC due to high heap utilization: " UINT_FMT " >= " UINT_FMT "\n" ,
487+ MP_STATE_MEM (gc_alloc_amount ), MP_STATE_MEM (gc_alloc_threshold ));
488+ #endif // MICROPY_GC_LOG
484489 gc_collect ();
490+ #if MICROPY_GC_LOG
491+ gc_dump_info ();
492+ #endif // MICROPY_GC_LOG
485493 collected = 1 ;
486494 GC_ENTER ();
487495 }
@@ -504,10 +512,21 @@ void *gc_alloc(size_t n_bytes, unsigned int alloc_flags) {
504512 GC_EXIT ();
505513 // nothing found!
506514 if (collected ) {
515+ #if MICROPY_GC_LOG
516+ printf ("OOM: cannot allocate " UINT_FMT " bytes after GC\n" , n_bytes );
517+ gc_dump_info ();
518+ #endif // MICROPY_GC_LOG
507519 return NULL ;
508520 }
509521 DEBUG_printf ("gc_alloc(" UINT_FMT "): no free mem, triggering GC\n" , n_bytes );
522+ #if MICROPY_GC_LOG
523+ gc_dump_info ();
524+ printf ("GC due to failed allocation: " UINT_FMT " bytes\n" , n_bytes );
525+ #endif // MICROPY_GC_LOG
510526 gc_collect ();
527+ #if MICROPY_GC_LOG
528+ gc_dump_info ();
529+ #endif // MICROPY_GC_LOG
511530 collected = 1 ;
512531 GC_ENTER ();
513532 }
You can’t perform that action at this time.
0 commit comments