Arduino在一段时间后崩溃了

I am working on an arduino project, that makes http requests on a server and reads the http page content. Ιn the loop I have a function:

String eventValue = check_for_event(); 

String check_for_event(){
if (client.connect(server, 80)) {
    client.print("GET /check_for_event.php?q=");
    client.print(class_code);
    client.println(" HTTP/1.0");
    client.println();

    return readPage(); 

} else{ return "704"; }
}

String readPage(){
  stringPos = 0;
  memset( &inString, 0, 32 );
  int print_flag=0;
  while(true){

    if (client.available()) {
      char c = client.read();
      if (c == '<' ) { 
        startRead = true; 
      }else if(startRead){
        if(c != '>'){ 
          inString[stringPos] = c;
          stringPos ++;
        }else{
          startRead = false;
          client.stop();
          client.flush();
          print_flag=1;
          return inString;
        }

      }
    }

  }
  if(print_flag==0){return "804";}
}

This is a part of my code and I call it every 3 seconds. It works fine for hours, but suddenly crashes and I can't understand why. I find out that crashes somewhere in the check_for_event function.

Most probably your are running out of memory. Since you do not show your code the exact reason is hard to identify. Either you have a memory leak or you just overflow your ram. I suggest to check if the size of the received http pages varies and if the crash only happens with particular large pages.

IMHO the Arduino with only 2k of ram is less than ideal for http processing. Something in the range of the Raspi would be way more appropriate.

Having said that, if you want to stick to the Arduino you might want to consider techniques for using less ram. The first thing is to learn about the available memory

The next is to stop wasting memory for string constants. If this is not sufficient -which is likely- you have to go through your code and optimize it a lot. Unless you are under tight cost constraints (e.g. because you design for 1000 of devices) or your time is basically free it is a much better idea to switch to stronger hardware.