LukeUSMC / ds18b20-photon

Dallas One-Wire temp sensor DS18XXX Particle Photon
MIT License
13 stars 32 forks source link

Memory leak when reinstatiating sensor object #5

Open ScruffR opened 8 years ago

ScruffR commented 8 years ago

As I found out here, there is a potential memory leak when using multiple instances of that library https://community.particle.io/t/ds18b20-switching-pins-during-execution/25727/15

This is easily fixed with the intrdocution of a destructor

DS18B20::~DS18B20() {
    delete(ds);
}

And if you're at it, could you also replace these macros, please?

with the now available functions


One the other hand it might even be better to remove the "private" implementatino of OneWire and just add a note to import that dependency (this will make getting this lib ready for Libraries 2.0 easier too).

LukeUSMC commented 8 years ago

Will do and thanks for the input. I need to get into the Lib 2.0 implementation, I spent 2 hours creating gulp tasks to check for updates, extract lib core files and moving them to the appropriate folder for testing. I hope the new lib system can be used more like a package manager like npm, bower, etc.