I was looking through the SD libarary and I found what looks like a potential memory leak. When a file is opened a malloc() is performed to get memory. When a file is closed the memory is freed.
But... If the file object is destroyed before the file is closed, the memory is never freed.
My suggestion would be to modify the destructor as follows:
Old code:
File::~File(void) {
// Serial.print("Deleted file object");
}
New code:
File::~File(void) {
close();
// Serial.print("Deleted file object");
}
Does this seek correct or am I way off here?