-
-
Notifications
You must be signed in to change notification settings - Fork 7k
memory leak in SD library - IDE 1.0 [imported] #814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is still a problem, and a nasty one. Can this fix PLEASE get pulled into trunk? I've verified the fix, and have to manually fix it every Arduino release. |
File isn't closed before being released, it leaks. This test has been verified and tested many times.
@bjelojac after having applied your patch, "listfiles" example does work anymore. Can you give it a spin and confirm? |
I've removed the File destructor. The safest way to free memory allocated by a File object is to call its close() method. listfiles example was no longer working because to the moment the compiler chooses to call an object destructor. In SD.cpp openNextFile method a new File is returned. However its destructor is called right after the object is created but before it is returned, leading openNextFile method to always return closed File instances. Removing the destructor enforces the role of the close() method, which must be called to free allocated memory and resources. |
Sorry wrong button. Please close the issue if you agree with previous comment or let's discuss the matter further |
File isn't closed before being released, it leaks. This test has been verified and tested many times.
Fix for arduino#814, Memory Leak
…lose/destructed objects arduino#814
Closing this, as there were no further discussions after Oct. 15, 2013. |
This is Issue 814 moved from a Google Code project.
Added by 2012-02-12T11:08:47.000Z by rob.till...@gmail.com.
Please review that bug for more context and additional comments, but update this bug.
Original labels: Type-Defect, Priority-Medium
Original description
JGoulder reported:
When a file is opened a malloc() is performed to get memory. When a file is closed the memory is freed. If the file object is destroyed before the file is closed, the memory is never freed.
Existing code:
File::~File(void) {
// Serial.print("Deleted file object");
}
JGoulder also proposed a fix:
File::~File(void) {
close();
// Serial.print("Deleted file object");
}
The text was updated successfully, but these errors were encountered: