Skip to content

Commit 61465c2

Browse files
authored
Add a delay to the http_server task
If you never give freeRTOS the time to run system tasks, you will see that the heap memory available will slowly go down over time until the program crashes. Simply adding a tiny delay allows the task to yield. The dramatic impact of this tiny change is easy to check if you create a 2nd task that does printf("free heap: %d\n",esp_get_free_heap_size()); Every 5s or so.
1 parent 207465f commit 61465c2

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

14_basic_webserver/main/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ static void http_server(void *pvParameters) {
160160
http_server_netconn_serve(newconn);
161161
netconn_delete(newconn);
162162
}
163+
vTaskDelay(1); //allows task to be pre-empted
163164
} while(err == ERR_OK);
164165
netconn_close(conn);
165166
netconn_delete(conn);

0 commit comments

Comments
 (0)