aboutsummaryrefslogtreecommitdiff
path: root/py/gc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-05-21 13:36:21 +1000
committerDamien George <damien.p.george@gmail.com>2018-05-21 13:36:21 +1000
commit6bd78741c13849da0570710ad6df80846df812c0 (patch)
treed0d228ae5bd086ebba4746abf041604bf5fa5b78 /py/gc.c
parentcac2eddc1634e65a1097646d11016298e6375f87 (diff)
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 #3786.
Diffstat (limited to 'py/gc.c')
-rw-r--r--py/gc.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/py/gc.c b/py/gc.c
index 38de51399..e92b81ece 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -453,6 +453,7 @@ void *gc_alloc(size_t n_bytes, bool has_finaliser) {
if (!collected && MP_STATE_MEM(gc_alloc_amount) >= MP_STATE_MEM(gc_alloc_threshold)) {
GC_EXIT();
gc_collect();
+ collected = 1;
GC_ENTER();
}
#endif