summaryrefslogtreecommitdiff
path: root/ports/esp32/gccollect.c
diff options
context:
space:
mode:
authorAngus Gratton <angus@redyak.com.au>2023-08-02 16:51:07 +1000
committerDamien George <damien@micropython.org>2023-08-15 10:50:46 +1000
commit05dcb8be9957d0ed6c9694629be186a40c1a3fd9 (patch)
tree67a372abfe26e7fced1f3a341d8347b44b066550 /ports/esp32/gccollect.c
parent98fd78437c56efeebe2e38c944f5af0a1a59fe8a (diff)
esp32: Enable automatic Python heap growth.
Via MICROPY_GC_SPLIT_HEAP_AUTO feature flag added in previous commit. Tested on ESP32 GENERIC_SPIRAM and GENERIC_S3 configurations, with some worst-case allocation patterns and the standard test suite. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
Diffstat (limited to 'ports/esp32/gccollect.c')
-rw-r--r--ports/esp32/gccollect.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/ports/esp32/gccollect.c b/ports/esp32/gccollect.c
index 6fa287de2..e16e8028a 100644
--- a/ports/esp32/gccollect.c
+++ b/ports/esp32/gccollect.c
@@ -80,3 +80,13 @@ void gc_collect(void) {
}
#endif
+
+#if MICROPY_GC_SPLIT_HEAP_AUTO
+
+// The largest new region that is available to become Python heap is the largest
+// free block in the ESP-IDF system heap.
+size_t gc_get_max_new_split(void) {
+ return heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT);
+}
+
+#endif