Go Down

Topic: Sd card stops working after a day of use. (Read 1 time) previous topic - next topic

physwm2501

I recently finished an rfid door access system for my house and everything works as intended.  The only issue I am having is after about a day of running the system, it will act is if the sd card has been removed or as if it can no longer access the card. 

I have attached a copy of the code I am using. 

fat16lib

Looks like there there are paths through the code where cardFile is opened but never closed.  This will cause a memory leak and SD operations will fail.

SD.h has a nasty property of allocating memory with malloc() when a file is opened and releasing the memory on close.  This often causes memory leaks.

SurferTim


SD.h has a nasty property of allocating memory with malloc() when a file is opened and releasing the memory on close.  This often causes memory leaks.

How does SdFat differ? I thought it did the same at about 500 bytes per open file.

physwm2501


Looks like there there are paths through the code where cardFile is opened but never closed.  This will cause a memory leak and SD operations will fail.

SD.h has a nasty property of allocating memory with malloc() when a file is opened and releasing the memory on close.  This often causes memory leaks.


why would the program still work then but the sd card fail?

So a solution would be to open the file after a card read is detected and then close the file when the operation is complete?

SurferTim

Quote
why would the program still work then but the sd card fail?

I don't know for certain, but if it is a well-mannered library, it will fail to open if there is insufficient memory to open the file.

Go Up