From 5a0c7d5944028730ad8110bb6f1b134185bfdcc9 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Fri, 23 Aug 2024 21:02:15 -0500 Subject: [PATCH] pybricks/tools/pb_module_tools: remove gc_collect() from run loop gc_collect() can take a long time to run (milliseconds) which means that it isn't possible to get smaller loop times than that. This was here in the first place to help prevent fragmentation, but there are alternative solutions, like setting gc.threshold() or manually running gc.collect() in an application that can handle the delay. --- CHANGELOG.md | 1 + pybricks/tools/pb_module_tools.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6be8191f3..4ca58ce46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ ### Fixed - Fixed not able to connect to new Technic Move hub with `LWP3Device()`. +- Removed `gc_collect()` from `tools.run_task()` loop to fix unwanted delays. [pybricks-micropython#250]: https://github.com/pybricks/pybricks-micropython/pull/250 [pybricks-micropython#253]: https://github.com/pybricks/pybricks-micropython/pull/253 diff --git a/pybricks/tools/pb_module_tools.c b/pybricks/tools/pb_module_tools.c index 88075380b..15ea1645a 100644 --- a/pybricks/tools/pb_module_tools.c +++ b/pybricks/tools/pb_module_tools.c @@ -239,8 +239,6 @@ static mp_obj_t pb_module_tools_run_task(size_t n_args, const mp_obj_t *pos_args while (mp_iternext(iterable) != MP_OBJ_STOP_ITERATION) { - gc_collect(); - if (loop_time == 0) { continue; }