Arduino ethernet Http Request Stops after a while

Hello everyone i have a Arduino Mega it goes to a web server and gets task every ten seconds, it works fine but after half an hour or 45 minutes it says

Connecting…
Connected.

and stops.
Here is what i think; it works like thousand times so code seems fine but maybe there are some problems with buffers or temperature. Thanks for your help

Code is as follows:

String httpRequest(char* server, char* path){
  tmpTaskList = "-";
  TaskList = "-";
  TaskFlag=0;

  
  Serial.println("connecting...");
  client.stop();


  if (client.connect(server, 80)) {
    Serial.println("connected");
    client.print("GET ");
    client.print(path);
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(server);
    client.println("Connection: close");
    client.println();
        
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
  
  while (client.available() || client.connected()){
          if (client.available()){
                  char c = client.read();
                  tmpTaskList += String(c);
          }
          if (!client.available() && !client.connected()){
                 for (int i=0;i < tmpTaskList.length();i++){
                          if(TaskFlag == 0){
                                 if(String(tmpTaskList[i]) == "#"){
                                         TaskFlag = 1;
                                 }
                         }else if(TaskFlag==1){
                                 if(String(tmpTaskList[i]) != "#"){
                                         TaskList += String(tmpTaskList[i]);
                                 }else {
                                         TaskFlag = 2;
                                 }
                         }
                 }
           return TaskList; 
           }
 }
}

but maybe there are some problems with buffers or temperature.

Or, the String class is fragmenting memory to the point where the Arduino can no longer function. Stop using that class.

what do you suggest i use instead

Post your entire sketch.

what do you suggest i use instead

C-style strings - NULL terminated array of chars.