diff options
| author | Dan Halbert <halbert@halwitz.org> | 2018-07-08 23:21:38 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-08 23:21:38 -0400 |
| commit | 64b9ee9c74dd3cc07400678caa7032d845358576 (patch) | |
| tree | a726389ca1073f5de907591f12b6a8d2e20ce6b5 /lib/utils | |
| parent | a45659c59a26a108924de88adb7f8d969cd7e5fc (diff) | |
| parent | 54179a01897ace60099b76690e7793d3241b1556 (diff) | |
Merge pull request #985 from tannewt/heap_tweaks3
A few heap related tweaks
Diffstat (limited to 'lib/utils')
| -rwxr-xr-x[-rw-r--r--] | lib/utils/pyexec.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/utils/pyexec.c b/lib/utils/pyexec.c index 718c6828c..929ee5224 100644..100755 --- a/lib/utils/pyexec.c +++ b/lib/utils/pyexec.c @@ -33,6 +33,7 @@ #include "py/runtime.h" #include "py/repl.h" #include "py/gc.h" +#include "py/gc_long_lived.h" #include "py/frozenmod.h" #include "py/mphal.h" #if defined(USE_DEVICE_MODE) @@ -97,6 +98,13 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input #endif } + // If the code was loaded from a file its likely to be running for a while so we'll long + // live it and collect any garbage before running. + if (input_kind == MP_PARSE_FILE_INPUT) { + module_fun = make_obj_long_lived(module_fun, 6); + gc_collect(); + } + // execute code mp_hal_set_interrupt_char(CHAR_CTRL_C); // allow ctrl-C to interrupt us start = mp_hal_ticks_ms(); |
