I'm using the ethernet shield to get a large amount of data (around 200 entries) from my server. The code below is simplified. In my actual loop, I break the request out into sections. Each entry will have around 2-13 characters. Here's my code:

So after around 35-ish objects, my data starts to corrupt. So I'm guessing I'm running out of memory.

This is the last possible method I can use... Strings aren't long enough to hold my data, writing/reading file is too memory intensive... And since it's writing to PROGMEM, it's not using RAM.. So why is it freezing up?

What form do the messages take? Do you need to store the entire incoming message, or can you compress or encode it? If you can halve the maximum size you need to store so that it is around 7 bytes maximum, then you can fit 200 messages in 1400 bytes, leaving you around 600 bytes (on a Uno) for other data and the stack.

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

What form do the messages take? Do you need to store the entire incoming message, or can you compress or encode it? If you can halve the maximum size you need to store so that it is around 7 bytes maximum, then you can fit 200 messages in 1400 bytes, leaving you around 600 bytes (on a Uno) for other data and the stack.

Thanks for the reply. I'm relatively new to this... I develop iPhone apps, so I don't have to mess with all this memory stuff. I always have plenty of memory to work with..

But I get it in this format: "500(1467)" Before the parenthesis, I have a delay time. And in the parenthesis, I have the LEDs that I want on. I will then play the matching WAV file using WaveRP and loop through all the data I have saved up. I switch the LEDs according to the sequence values (in the parenthesis) & delay the amount of milliseconds (found before the parenthesis). The number of entries differ, but I would say it's between 200-300 values.

I've tried playing the song, and reading the data all in the main loop(), and it started acting weirdly (I'm guessing it ran out of memory, or was close to it). So I then tried writing all the data to a txt file, and running it later. But then I realized you can't read 2 files off the SD card at once *face palm*. I also tried appending it all to a String and reading it later, but after 40-ish characters the data went corrupt... And again, started acting weirdly.

What you need to do is parse the data either as you receive it or whenever you have received a complete message. That way you only need to store the 2 integers in the message, which takes 2 bytes per integer, assuming a 16-bit unsigned range is enough. So 4 bytes per message. If you have 300 of them, that's 1200 bytes, leaving 824 free out of the 2K available on most Arduinos.

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

What you need to do is parse the data either as you receive it or whenever you have received a complete message. That way you only need to store the 2 integers in the message, which takes 2 bytes per integer, assuming a 16-bit unsigned range is enough. So 4 bytes per message. If you have 300 of them, that's 1200 bytes, leaving 824 free out of the 2K available on most Arduinos.

Okay, that somewhat works. However, it stops randomly around halfway through the WAV file. I'm using this function to check the RAM usage...

1. Don't use the String class, it causes memory fragmentation. Learn to use character arrays instead. You can use the atoi function for extracting and integer form a character array. Be sure to write your code so that you do not overflow the character array if the input does not conform to expectations.

2. If the Ethernet client library supports it, use F strings when printing string literals to it, like this:

1. Don't use the String class, it causes memory fragmentation. Learn to use character arrays instead. You can use the atoi function for extracting and integer form a character array. Be sure to write your code so that you do not overflow the character array if the input does not conform to expectations.

2. If the Ethernet client library supports it, use F strings when printing string literals to it, like this: