esp-cpp / espp

C++ components for ESP
https://esp-cpp.github.io/espp/
MIT License
28 stars 9 forks source link

fix(timer): Fix memory leak in `espp::HighResolutionTimer` when calling start repeatedly #226

Closed finger563 closed 2 months ago

finger563 commented 2 months ago

Description

Motivation and Context

When reviewing the code, it was determined that repeated calls to start(...) (even if they included stop()), would leak memory as esp_timer_create(...) was called multiple times without calling esp_timer_delete(...).

This PR fixes that problem by ensuring that stop() calls esp_timer_delete(...) if the timer_handle is not null.

How has this been tested?

Building and running the timer/example on a QtPy ESP32s3.

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

CleanShot 2024-05-06 at 13 48 40

Types of changes

Checklist:

Software

github-actions[bot] commented 2 months ago

:white_check_mark:Static analysis result - no issues found! :white_check_mark: