Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore automatic gc_collect() after an import #6406

Merged
merged 1 commit into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,10 @@ msgstr ""
msgid "Failed to acquire mutex, err 0x%04x"
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/raspberrypi/common-hal/busio/UART.c
msgid "Failed to allocate RX buffer"
Expand Down
4 changes: 4 additions & 0 deletions py/builtinimport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
// 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))) {
Expand Down
2 changes: 1 addition & 1 deletion shared-module/rgbmatrix/RGBMatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t *self,
mp_raise_ValueError(translate("Invalid argument"));
break;
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);
tannewt marked this conversation as resolved.
Show resolved Hide resolved
break;
default:
mp_raise_msg_varg(&mp_type_RuntimeError,
Expand Down