summaryrefslogtreecommitdiffstatshomepage
path: root/py/gc.h
diff options
context:
space:
mode:
authorAyke van Laethem <aykevanlaethem@gmail.com>2018-01-24 02:09:58 +0100
committerDamien George <damien@micropython.org>2022-07-23 00:42:54 +1000
commitbcc827d695e20b644ff4626bd529e3d8706716d7 (patch)
tree62b475268a2fb5d6035e8e83b22a55e9e4a1127b /py/gc.h
parent5dbb822ca4a809ac5cb4513afb0411b4eb8dc3cf (diff)
downloadmicropython-bcc827d695e20b644ff4626bd529e3d8706716d7.tar.gz
micropython-bcc827d695e20b644ff4626bd529e3d8706716d7.zip
py/gc: Allow the GC heap to be split over multiple memory areas.
This commit adds a new option MICROPY_GC_SPLIT_HEAP (disabled by default) which, when enabled, allows the GC heap to be split over multiple memory areas/regions. The first area is added with gc_init() and subsequent areas can be added with gc_add(). New areas can be added at runtime. Areas are stored internally as a linked list, and calls to gc_alloc() can be satisfied from any area. This feature has the following use-cases (among others): - The ESP32 has a fragmented OS heap, so to use all (or more) of it the GC heap must be split. - Other MCUs may have disjoint RAM regions and are now able to use them all for the GC heap. - The user could explicitly increase the size of the GC heap. - Support a dynamic heap while running on an OS, adding more heap when necessary.
Diffstat (limited to 'py/gc.h')
-rw-r--r--py/gc.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/py/gc.h b/py/gc.h
index 5aef27c006..bb4204b06f 100644
--- a/py/gc.h
+++ b/py/gc.h
@@ -28,9 +28,15 @@
#include <stdbool.h>
#include <stddef.h>
+#include "py/mpconfig.h"
void gc_init(void *start, void *end);
+#if MICROPY_GC_SPLIT_HEAP
+// Used to add additional memory areas to the heap.
+void gc_add(void *start, void *end);
+#endif
+
// These lock/unlock functions can be nested.
// They can be used to prevent the GC from allocating/freeing.
void gc_lock(void);