Skip to content

Commit 4fcc8e1

Browse files
committed
Dynamic memory cleanup
1 parent 3f3cf0f commit 4fcc8e1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

shared-module/displayio/__init__.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ static bool any_display_uses_this_framebuffer(mp_obj_base_t *obj) {
100100
}
101101
#endif
102102

103-
104103
void displayio_background(void) {
105104
if (mp_hal_is_interrupted()) {
106105
return;
@@ -253,8 +252,15 @@ void malloc_display_memory(void) {
253252
void reset_displays(void) {
254253
// In CircuitPython 10, release secondary displays before doing anything else:
255254
common_hal_displayio_release_displays_impl(true);
255+
#if CIRCUITPY_OS_GETENV && CIRCUITPY_SET_DISPLAY_LIMIT
256256
// Set dynamically allocated displays to 0 (CIRCUITPY_DISPLAY_LIMIT)
257257
max_allocated_display = CIRCUITPY_DISPLAY_LIMIT;
258+
// Does this need to be done or dos port_free effectively do this?
259+
m_del(primary_display_bus_t, display_buses_dyn, (max_allocated_display - CIRCUITPY_DISPLAY_LIMIT));
260+
m_del(primary_display_t, displays_dyn, (max_allocated_display - CIRCUITPY_DISPLAY_LIMIT));
261+
display_buses_dyn = NULL;
262+
displays_dyn = NULL;
263+
#endif
258264

259265
// The SPI buses used by FourWires may be allocated on the heap so we need to move them inline.
260266
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {

0 commit comments

Comments
 (0)