Arduino MEGA and Ethernet Shield chipset, program will reset when count > 10000

Hi All,
I got a strange case, the arduino program will reset itself when the counter reach 10000.
I use the Mage(ATmega 12800) and the EthernetShield (chipset w5100), try to send data to server by php.
I use the EPROM to read the MAc Address from the EPROM, and DHCP to get IP address from the DHCP Server. It work and upload the value to the server. After checking the database, I found that the program will reset after the counter reach 10000, checking the record times stamp, look like the board running program has been reset. Initially, I do think that may be the integer counter reach the limit, I split the counter into high and low value and combine it in the server, the problem still exist.
Do anyone encounter such issue? Can anyone give me some advise to solve this problem?
I also try to use the UNO board and just serial print the unsigned long integer counter value, it can print without reset.
Attach the code, for reference.

#include <Ethernet.h>
#include <SPI.h>
#include <utility\w5100.h>
#include <EthernetDHCP.h>
#include <EEPROM.h>

#define buardrate 9600
#define reinitRate 500
#define fUpperTemp 35 
#define fUpperHumi 85 
byte server[] = {192,168,3,222};
byte subnet[] = { 255, 255, 255, 0 };
byte ip[4] ;
byte gateway[4];
byte mac[6];
boolean bolGetIP ; 
long int debounceDelay ; 
long int mycount ; 
int temp_count ; 
int temp_count_h ; 
char inString[600]; // string for incoming serial data
int stringPos = 0; // string index counter
boolean startRead = false; // is reading?
float tempture ; 
float humidity ; 
unsigned long int intRead ; 
void setup()
{
  int count ; 
  
  mycount = 0 ;
  temp_count_h = 0 ; 
  temp_count = 9990 ; 
  for (count = 0; count < 6 ; count ++) 
  {
    mac[count] = EEPROM.read(count);
  }
  count = 0 ; 
  Serial.begin(buardrate);
  EthernetDHCP.begin(mac, 1);
  bolGetIP = false ;
  Serial.println("DHT22 TEST PROGRAM ");
  Serial.print("LIBRARY VERSION: ");
  Serial.println();
}

void loop ()
{
  static DhcpState prevState = DhcpStateNone;
  static unsigned long prevTime = 0;
  
  DhcpState state = EthernetDHCP.poll();
  if (prevState != state) {
    Serial.println();
    switch (state) {
      case DhcpStateDiscovering:
        Serial.print("Discovering servers.");
        break;
      case DhcpStateRequesting:
        Serial.print("Requesting lease.");
        break;
      case DhcpStateRenewing:
        Serial.print("Renewing lease.");
        break;
      case DhcpStateLeased: {
        Serial.println("Obtained lease!");
        const byte* ipAddr = EthernetDHCP.ipAddress();
        const byte* gatewayAddr = EthernetDHCP.gatewayIpAddress();
        const byte* dnsAddr = EthernetDHCP.dnsIpAddress();        
        Serial.print("My IP address is ");
        ip[0]=ipAddr[0];
        ip[1]=ipAddr[1];
        ip[2]=ipAddr[2];
        ip[3]=ipAddr[3];
        Serial.println(ip_to_str(ipAddr));
        Serial.print("Gateway IP address is ");
        Serial.println(ip_to_str(gatewayAddr));
        gateway[0]=gatewayAddr[0];
        gateway[1]=gatewayAddr[1];
        gateway[2]=gatewayAddr[2];
        gateway[3]=gatewayAddr[3];        
        Serial.print("DNS IP address is ");
        Serial.println(ip_to_str(dnsAddr));
        bolGetIP = true ;         
        Serial.println();        
        break;
      }
    }
  } else if (state != DhcpStateLeased && millis() - prevTime > 300) {
     prevTime = millis();
     Serial.print('.'); 
  }
  if (bolGetIP == true) {  
  getTemp();
  Serial.print("Humidity (%): ");
  Serial.println((float)humidity, 2);
  Serial.print("Temperature (oC): ");
  Serial.println((float)tempture, 2);
 delay(2000);
  }
  prevState = state;
}

const char* ip_to_str(const uint8_t* ipAddr)
{
  static char buf[16];
  sprintf(buf, "%d.%d.%d.%d\0", ipAddr[0], ipAddr[1], ipAddr[2], ipAddr[3]);
  return buf;
}

void getTemp()
{
  boolean bolSend ; 
  float myTemper ; 
  float myHumi ;
  int intResend_c ;

  intResend_c = 0 ;
  Serial.println("\n");
  temp_count ++ ; 
  if(temp_count > 10000 )
  {
     temp_count_h = temp_count_h + 1 ;
     temp_count = temp_count % 10000 ;  
  }
  tempture = 22 ;
  humidity = 66 ;
  Serial.print("Humidity (%): ");
  Serial.println(humidity);
  Serial.print("Temperature (oC): ");
  Serial.println(tempture);
    myTemper = tempture;
    myHumi = humidity ;    
   String pageValue = sendToServer(humidity, tempture,temp_count, temp_count_h ,intResend_c); 
   Serial.print("IntRead:=");
   Serial.println(intRead);
   Serial.print("temp_count:=");
   Serial.println(temp_count);
   if (intRead!=temp_count)
   {
     reinitnet(); 
     Serial.println("Go in the Send twice!");
     pageValue = sendToServer(humidity, tempture,temp_count,temp_count_h,intResend_c++); 
   }
   Serial.println(pageValue);
   Serial.print("Read Back:=");
   Serial.println(intRead);
}

String sendToServer(float fhumi , float ftemp,  int t_count , int t_count_h , int t_resend )
{ 
  int localint ; 
  char LocalStr[20];
  char *p = LocalStr;
  Client client(server, 80); // port 80 is typical www page  
  
  memset( LocalStr, 0, sizeof(LocalStr) );
  dtostrf(fhumi,2,2,p);
  String location = "/arduino/envior3.php?humi=" ; 
  location.concat(LocalStr);
  location.concat("&temper=");
  memset( LocalStr, 0, sizeof(LocalStr) );
  dtostrf(ftemp,2,2,p);
  location.concat(LocalStr);
  location.concat("&t_count=");
  memset( LocalStr, 0, sizeof(LocalStr) );
  sprintf(p,"%d",t_count);
  location.concat(LocalStr);
  location.concat("&h_count=");
  memset( LocalStr, 0, sizeof(LocalStr) );
  sprintf(p,"%d",t_count_h);
  location.concat(LocalStr);  
  location.concat("&t_resend=");
  memset( LocalStr, 0, sizeof(LocalStr) );
  dtostrf(t_resend,1,0,p);
  location.concat(LocalStr);
  Serial.print("t_count:=");
  Serial.println(t_count);
  Serial.println(location);
  location.concat(" HTTP/1.0"); 
  if (client.connect()) {
    client.print("GET ");
    client.println(location);
    client.println();
    return readPage(client); //go and read the output
  }else{
    intRead = 0 ; 
    return "connection failed Delay 5 Sec";
  } 
}

String readPage(Client myClient){
  unsigned long int ret_int ;
  startRead = false ;
  stringPos = 0;
  memset( &inString, 0, 600 ); //clear inString memory
  intRead = 0 ;
  while(true){
    if (myClient.available()) {
      char c = myClient.read();
      Serial.print(c);
      if (c == '<' ) { //'<' is our begining character
        startRead = true; //Ready to start reading the part 
      }else if(startRead){
        if(c != '>'){
          inString[stringPos] = c;
          stringPos ++;
        }else{
          startRead = false;
          myClient.stop();
          myClient.flush();
          sscanf(inString,"%lu",&intRead);
          Serial.print("Return :=");
          Serial.println(intRead);
          return inString;
        } //End of Else 
      } //End of if(startRead)
    } //End of if (client.available())
  } //End of While(1)
} //End of readPage()

void reinitnet()
{
      W5100.init();
      W5100.setMACAddress(mac);
      W5100.setIPAddress(ip);
      W5100.setGatewayIp(gateway);
      W5100.setSubnetMask(subnet);    
}
// END OF FILE

You are probably running out of memory.

Try recoding without using the String class.

Thanks Nick’s Comment.
I re-write the program and exclude the String Class, now the program still running without reset.