diff options
| author | Damien George <damien@micropython.org> | 2023-06-22 17:31:40 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-03-22 13:10:05 +1100 |
| commit | 98a8ff7a1a42211acc62e5c41a445a9d6f256e70 (patch) | |
| tree | d0d5f950a2aec3a2ed50abf6b918ae4c57030373 /ports/webassembly/main.c | |
| parent | ae6bcc9d2345d73016fd22f9cc22b56c73bae432 (diff) | |
webassembly: Add support for enabling MICROPY_GC_SPLIT_HEAP_AUTO.
When enabled the GC will not reclaim any memory on a call to
`gc_collect()`. Instead it will grow the heap.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'ports/webassembly/main.c')
| -rw-r--r-- | ports/webassembly/main.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ports/webassembly/main.c b/ports/webassembly/main.c index 1b053046b..ebde8ac70 100644 --- a/ports/webassembly/main.c +++ b/ports/webassembly/main.c @@ -113,6 +113,19 @@ void mp_js_init_repl() { pyexec_event_repl_init(); } +#if MICROPY_GC_SPLIT_HEAP_AUTO + +// The largest new region that is available to become Python heap. +size_t gc_get_max_new_split(void) { + return 128 * 1024 * 1024; +} + +// Don't collect anything. Instead require the heap to grow. +void gc_collect(void) { +} + +#else + static void gc_scan_func(void *begin, void *end) { gc_collect_root((void **)begin, (void **)end - (void **)begin + 1); } @@ -124,6 +137,8 @@ void gc_collect(void) { gc_collect_end(); } +#endif + #if !MICROPY_VFS mp_lexer_t *mp_lexer_new_from_file(qstr filename) { mp_raise_OSError(MP_ENOENT); |
