I have this code below and I have an ESP8266 board before entering it in the media I have 40000 bytes and after executing the http it drops to 17000. I have already changed to MQTT and it is the same memory consumption.
I am checking the code in the looping and if it entered it no longer calls the function executaConsulta but the memory using getFreeHeap does not return to 40000 bytes. I noticed that to return I need to disconnect the board from the internet. Is there a better way?
Code: Select all
973 / 5.000
void executaConsulta(int bombaID) {
Serial.println("executarConsulta");
Serial.println("bombaID");
Serial.println(bombaID);
// Simulates the creation of the URL
String url = String(serverApi) + "?email=" + email + "&senha=" + senha;
// Start the HTTP request
http.begin(client, url);
http.addHeader("Content-Type", "application/json");
http.addHeader("Connection", "keep-alive");
int httpResponseCode = http.GET(); // Make the GET request
Serial.print("httpResponseCode: ");
Serial.println(httpResponseCode);
if (httpResponseCode > 0) {
Serial.println("Response: " + http.getString());
} else {
Serial.println("HTTP Error");
}
http.end(); // Ends the request and frees the memory
// Calls a function to force garbage collection (collecting unused memory)
yield(); // Forces the release of memory and prevents the ESP8266 from crashing
printMemoryStatus("End of query");
}