Skip to content

Commit 6bd7874

Browse files
committed
py/gc: When GC threshold is hit don't unnecessarily collect twice.
Without this, if GC threshold is hit and there is not enough memory left to satisfy the request, gc_collect() will run a second time and the search for memory will happen again and will fail again. Thanks to @adritium for pointing out this issue, see adafruit#3786.
1 parent cac2edd commit 6bd7874

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

py/gc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ void *gc_alloc(size_t n_bytes, bool has_finaliser) {
453453
if (!collected && MP_STATE_MEM(gc_alloc_amount) >= MP_STATE_MEM(gc_alloc_threshold)) {
454454
GC_EXIT();
455455
gc_collect();
456+
collected = 1;
456457
GC_ENTER();
457458
}
458459
#endif

0 commit comments

Comments
 (0)