Skip to content

Commit d776ec2

Browse files
Fix memory leak in tone/noTone calls (#125)
Was never deleting the tone object on noTone, so eventually the leaked objects would fill up heap and cause a crash. Fixes #121
1 parent 8ae69a3 commit d776ec2

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

cores/rp2040/Tone.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ void noTone(uint8_t pin) {
9595
if (entry != _toneMap.end()) {
9696
pio_sm_set_enabled(entry->second->pio, entry->second->sm, false);
9797
pio_sm_unclaim(entry->second->pio, entry->second->sm);
98+
delete entry->second;
9899
_toneMap.erase(entry);
99100
pinMode(pin, OUTPUT);
100101
digitalWrite(pin, LOW);

0 commit comments

Comments
 (0)