Low on memory any ideas?

Hi all, running a little low on memory on my Uno, looking at the code -> http://codepad.org/XY494JZ8, is there anything that could be changed to help free some up?

The available free memory is output every 6 seconds along with the results of the ping.

Appreciate any assistance, thanks.

First trick. Wherever you have print("something in inverted commas") replace it with print(F("something in inverted commas"));

What's the point of StrContains?

What's wrong with strstr_P?

It's not much, but do all of these variables need to be ints or could some/all be bytes ?

const int FanSwitchPIN = 7;
const int RebootPIN = 8;
const int TempSensorPIN = 0;

int buttonState = 0;
int TempSensor = 0;
int BadPingCnt = 0;
int PCReset = 0;

The pin numbers obviously don't. Are there any local variables in functions that could be declared as smaller data types ?

Does your linked code work?

Serial.println("setup loop");
Ethernet.begin(mac, ip);
server.begin();           // start to listen for clients

I did not realize you could start printing to serial before it's initialized?

I'd re-evaluate the use of "printf / sprintf", and whether their convenience is worth allocating 12.5% of my memory to "buffer". I'm guessing "__FlashStringHelper*" errors are why the F() macro isn't being used inside sprintf lines, which ties up another 55+ bytes for storing the templates for those sprintf calls.

"PingTime" is overflowing, it has room for "Reboot". Maybe you meant to use "buffer" instead?

printf(PingTime,"%s", "Rebooting");

It looks like the main issue comes down to output buffering being anticipated, but strayed away from. So that sizable "buffer" variable, combined with smaller redundant variables designed to improve readability, but eventually leading to variable confusion like what happened in "PingTime", ends up eating more memory than is needed.

Thanks all for the replies, yes the code does work. I'll try as suggested and reply with the outcome next week.

Much appreciated.