Pages: [1]   Go Down
Author Topic: malloc() bug and SD cards  (Read 611 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does anybody know if the malloc() bug that causes memory leaks with Strings also affects the SD card libary? There are various references to SD library using malloc().

I'm having a problem with a Uno and Ethernet card which looks like a clasic memory shortage problem. The Arduino is logging the temperatures at various places in a hot watertank, saving the data to an SD card every 10min and acting as a web server so that the data can be pulled off over the ethernet. Every so often the ethernet locks up (ping times out) or it stops writing data to the card.

I have discovered that there is usually 588 bytes of sram free through all but one of the routines that the sketch goes through and this does not reduce in the long term so when the SD libary is invoked there should be enough room for the SD's 512 byte buffer.

I won't post the code because it runs to 28Kbyte at the moment and I'm trying to simplify it.

Offline Offline
God Member
Karma: 39
Posts: 986
Get Bitlash:
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you aren't detecting a long-term leak the next most likely source is a buffer overflow or some other species of wild pointer.

About which it will be difficult to provide help until you post your code.


Sydney, Australia
Online Online
Edison Member
Karma: 27
Posts: 1188
Big things come in large packages
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

TYhe SD library that comes with Arduino has a memory leak that shows itself when you open/close file repeatedly. I use the SDFat library - faster and no memory leaks.

Arduino libraries
Parola hardware & library

Pages: [1]   Go Up
Jump to: