1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

esp32: report heap changes

This commit is contained in:
Andy Green 2017-09-11 10:23:30 +08:00
parent 0186490fad
commit a3cc4a368e
3 changed files with 24 additions and 0 deletions

View file

@ -798,6 +798,10 @@ lws_create_context(struct lws_context_creation_info *info)
else
context->pt_serv_buf_size = 4096;
#if defined(LWS_WITH_ESP32)
context->last_free_heap = esp_get_free_heap_size();
#endif
/* default to just the platform fops implementation */
context->fops_platform.LWS_FOP_OPEN = _lws_plat_file_open;

View file

@ -117,6 +117,22 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
pt = &context->pt[tsi];
lws_stats_atomic_bump(context, pt, LWSSTATS_C_SERVICE_ENTRY, 1);
{
unsigned long m = lws_now_secs();
if (m > context->time_last_state_dump) {
context->time_last_state_dump = m;
n = esp_get_free_heap_size();
if (n != context->last_free_heap) {
if (n > context->last_free_heap)
lwsl_info(" heap :%d (+%d)\n", n, n - context->last_free_heap);
else
lwsl_info(" heap :%d (-%d)\n", n, context->last_free_heap - n);
context->last_free_heap = n;
}
}
}
if (timeout_ms < 0)
goto faked_service;

View file

@ -998,6 +998,10 @@ struct lws_context {
uint64_t last_dump;
int updated;
#endif
#if defined(LWS_WITH_ESP32)
unsigned long time_last_state_dump;
uint32_t last_free_heap;
#endif
int max_fds;
#if defined(LWS_USE_LIBEV) || defined(LWS_USE_LIBUV) || defined(LWS_USE_LIBEVENT)