How much ram does a socket connection consume?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

How much ram does a socket connection consume?

Postby kolban » Fri Dec 16, 2016 8:41 pm

I am working on a large project (a JavaScript runtime). I am starting to find that I am beginning to get "squeezed" on RAM. One of the things I seem to be finding is that when I have an active socket connection from a PC based client into my ESP32, the ESP32 seems to want to use ~20K of RAM to host that connection. When I close the socket, I get the RAM back. When I open a new socket, the free ram shrinks by about ~20K. My core question ... do we know what the anticipated overhead is in terms of RAM utilization in having a socket open.

I also find myself confused about the 512K statements about an ESP32 and the apparent ~200K of free heap shown to my application. I had assumed that the missing 300K might have been used for WiFi and network maintenance ... but if sockets are eating my ~200K ... my comprehension must be flawed.

Later ...
I did a bunch of memory tests using esp_get_free_heap_size() using a brand new C app ... and was unable to reproduce anything on the order of 20K. It seems that a new socket needs about 700 bytes and despite lots of pushes and pulls to it using the Linux "nc" command, haven't so far found any issues.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Who is online

Users browsing this forum: No registered users and 215 guests