mandulaj / PZEM-004T-v30

Arduino library for the Updated PZEM-004T v3.0 Power and Energy meter
MIT License
256 stars 108 forks source link

Deleting a PZEM004Tv30 on SoftwareSerial leaks memory #61

Closed FXeio closed 2 years ago

FXeio commented 3 years ago

Describe the bug When the destructor is called on a PZEM004Tv30 using SoftwareSerial, the library deletes the _serial, but _serial is declared as Stream*, which doesn't actually call the proper SoftwareSerial's destructor

To Reproduce Steps to reproduce the behavior:

  1. Create a new PZEM004Tv30 using SoftwareSerial
  2. Delete it
  3. SoftwareSerial is not closed and memory is leaked (on Espressif platforms you can check this with ESP.freeHeap())
mandulaj commented 2 years ago

Great catch! I will merge this right away!