Lenoardo going to sleep?

Hi,
I'm pretty new to all this stuff so if this is a stupid question please forgive my ignorance.

I'm using a Leonardo with the official GSM shield v1 - the final aim of my project is to build a remote alerting power failure alarm but at the moment I am just playing with the GSM side of things.

I have a sketch that will receive a text message and then echo it back to the same number it came from - this works fine, but I find after 'a while' of not contacting it (I have no idea how long the 'while' is, but it's >>hrs) it stops responding. The only way to get the system responding again is is to press the 'reset' button on the Leonardo or GSM shield.

Is this because the Leonardo or perhaps the GSM shield is going to sleep? If so, how do I stop it? I've read the ('sleep' article but I couldn't really get my head round it and it seems to be more about putting it to sleep rather than preventing it going to sleep (if that is indeed what is happening)

TIA
Rob

Are you using the String class? If so, how many percent of "dynamic memory" is shown as used when you compile?

Yes, I just 'amended' the examples in the GSM libarary.

Sketch uses 18,956 bytes (66%) of program storage space. Maximum is 28,672 bytes.
Global variables use 886 bytes (34%) of dynamic memory, leaving 1,674 bytes for local variables. Maximum is 2,560 bytes.

/*
 SMS receiver

 This sketch, for the Arduino GSM shield, waits for a SMS message
 and displays it through the Serial port.

 Circuit:
 * GSM shield attached to and Arduino
 * SIM card that can receive SMS messages

 created 25 Feb 2012
 by Javier Zorzano / TD

 This example is in the public domain.

 http://www.arduino.cc/en/Tutorial/GSMExamplesReceiveSMS

*/

// include the GSM library
#include <GSM.h>

// PIN Number for the SIM
#define PINNUMBER ""

// initialize the library instances
GSM gsmAccess;
GSM_SMS sms;

// Array to hold the number a SMS is retreived from
char senderNumber[20];
String Message;
String EchoMessage;

void setup() {


  // connection state
  boolean notConnected = true;

  // Start GSM connection
  while (notConnected) {
    if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
      notConnected = false;
    } else {
     
      delay(1000);
    }
  }


}

void loop() {
  char c;

  // If there are any SMSs available()
  if (sms.available()) {
    

    // Get remote number
    sms.remoteNumber(senderNumber, 20);
   

    // An example of message disposal
    // Any messages starting with # should be discarded
    if (sms.peek() == '#') {
      
      sms.flush();
    }

    // Read message bytes
    while (c = sms.read()) {
      
      Message +=c ;
    }

    

    // Delete message from modem memory
    sms.flush();
    
    EchoMessage=("ECHO > "+Message);
    EchoMessage+=" SENDER > ";
    sms.beginSMS(senderNumber);
    sms.print(EchoMessage+senderNumber);
    sms.endSMS();
    
    Message="\0";
  }

  delay(1000);

}