I’m playing around with writing strings to an SD card (that is triggered when a server connection is unavailable). It subsequently logs the sensor values to the SD card (within the regular loop() function) and once a connection to the server becomes available, it sends this as a packet over UDP.
I seem to be running into some pretty large memory leaks that occur once this SD card write section is entered, which eventually causes the Arduino to run out of free memory.
Ok, I read that code — if you don’t call close() for every case of an open you will have a leak — there is only one file object (why I don’t know).
Here is the interesting code:
They seem to have some nice code for finding leak right there… maybe you should try it.
Also just go and change the code at the end to look like this:
Well you don’t show us the code for the SD object so it is a mystery but I expect you need to call dispose on something… maybe dataFile?