arkhipenko / TaskScheduler

Cooperative multitasking for Arduino, ESPx, STM32, nRF and other microcontrollers
http://playground.arduino.cc/Code/TaskScheduler
BSD 3-Clause "New" or "Revised" License
1.32k stars 243 forks source link

delete manually disabled self-destruct tasks #181

Closed schlimmchen closed 10 months ago

schlimmchen commented 10 months ago

adjusts an example to disable a single task before it runs out of iterations. the task disables itself. without the fix in TaskScheduler.h, one can observe a memory leak, as the task which disabled itself is not deleted.

the TaskScheduler is adjusted to check the self-destruct request flag of disabled tasks and to delete such tasks.

output of original example

Free mem=354580 No of tasks=0

        No of tasks=0
        Free mem=354580

output of modified example without fix:

Free mem=354572 No of tasks=0

        No of tasks=0
        Free mem=354488

output of modified example with fix:

Free mem=354572 No of tasks=0

        No of tasks=0
        Free mem=354572
schlimmchen commented 10 months ago

notice that the example which is modified in this PR needs #180 to compile.

arkhipenko commented 10 months ago

Pushed into testing branch as v3.8.4