Go Down

Topic: SD Library Potential Memory Leak (Read 1 time) previous topic - next topic


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:
Code: [Select]

File::~File(void) {
  //  Serial.print("Deleted file object");

New code:
Code: [Select]

File::~File(void) {
  //  Serial.print("Deleted file object");

Does this seek correct or am I way off here?


Does this seek correct or am I way off here?

Yes, it is correct. No, you are not way off. Not even a little off.
The art of getting good answers lies in asking good questions.


Feb 12, 2012, 11:57 am Last Edit: Feb 12, 2012, 12:09 pm by robtillaart Reason: 1
Thanks Jgoulder,

I reported it here - http://code.google.com/p/arduino/issues/detail?id=814&thanks=814&ts=1329044927 -
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131