Merge pull request #6406 from dhalbert/restore-gc-collect-on-import

Restore automatic gc_collect() after an import
This commit is contained in:
Scott Shawcroft 2022-05-18 11:08:36 -07:00 committed by GitHub
commit 46378550ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -1022,6 +1022,10 @@ msgstr ""
msgid "Failed to acquire mutex, err 0x%04x" msgid "Failed to acquire mutex, err 0x%04x"
msgstr "" msgstr ""
#: shared-module/rgbmatrix/RGBMatrix.c
msgid "Failed to allocate %q buffer"
msgstr ""
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
#: ports/raspberrypi/common-hal/busio/UART.c #: ports/raspberrypi/common-hal/busio/UART.c
msgid "Failed to allocate RX buffer" msgid "Failed to allocate RX buffer"

View File

@ -455,6 +455,10 @@ STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name,
// not a package. This will be caught on the next iteration // not a package. This will be caught on the next iteration
// because the file will not exist. // because the file will not exist.
} }
// Loading a module thrashes the heap significantly so we explicitly clean up
// afterwards.
gc_collect();
} }
if (outer_module_obj != MP_OBJ_NULL && VERIFY_PTR(MP_OBJ_TO_PTR(outer_module_obj))) { if (outer_module_obj != MP_OBJ_NULL && VERIFY_PTR(MP_OBJ_TO_PTR(outer_module_obj))) {

View File

@ -123,7 +123,7 @@ void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t *self,
mp_raise_ValueError(translate("Invalid argument")); mp_raise_ValueError(translate("Invalid argument"));
break; break;
case PROTOMATTER_ERR_MALLOC: case PROTOMATTER_ERR_MALLOC:
mp_raise_msg(&mp_type_MemoryError, NULL); mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate %q buffer"), MP_QSTR_RGBMatrix);
break; break;
default: default:
mp_raise_msg_varg(&mp_type_RuntimeError, mp_raise_msg_varg(&mp_type_RuntimeError,