smart-swimmingpool / pool-controller

🏊 Smart Swimming Pool 2.0 - ESP8266 based Controller managing your swimming pool
https://smart-swimmingpool.com/
MIT License
18 stars 7 forks source link

Memory leaks #7

Closed MrTroble closed 2 years ago

MrTroble commented 4 years ago

https://github.com/smart-swimmingpool/pool-controller/blob/97b6b59d9d36d87e5567086f0d6f9f531a3b8d4a/src/DallasTemperatureNode.cpp#L28-L29

Sie zerstören die Memory nie, da sie keinen Dekonstruktor haben. Daher entsteht hier ein Memory leak, weil die Ressourcen nicht mehr freigegeben werden.

"An object created by 'new' lives until destroyed by delete" - Bjarne Stroustrup, A Tour of C++

Ich schlage vor einfach das new weg zu lassen und die (de)allocation RAII zu überlassen.

oneWire = OneWire(_pin); 
sensor  = DallasTemperature(oneWire);

Ich würde auch raten das überall zu ändern.

MrTroble commented 4 years ago

I will try to make a PR to fix all memory leaks that I can find in the next couple of days. Let's see how this will go...