Pages: [1]   Go Down
Author Topic: malloc() bug and SD cards  (Read 733 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
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.
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
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.

-br
Logged

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1284
Big things come in large packages
View Profile
WWW
 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.
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Pages: [1]   Go Up
Jump to: