Skip to content

Commit

Permalink
pybricks/tools/pb_module_tools: remove gc_collect() from run loop
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dlech committed Aug 24, 2024
1 parent d808bfd commit 5a0c7d5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions pybricks/tools/pb_module_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 5a0c7d5

Please sign in to comment.