Skip to content

Memory loss of 184 bytes at each request #2332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
marcoschwartz opened this issue Jul 27, 2016 · 3 comments
Closed

Memory loss of 184 bytes at each request #2332

marcoschwartz opened this issue Jul 27, 2016 · 3 comments

Comments

@marcoschwartz
Copy link

Hello,

I am the creator of the aREST library, which is also compatible with the ESP8266 and uses this library to work. We found out that at each request to the board (the sketch is running a web server on the board), we loose 184 bytes of memory. I think it's related to this issue:

#1923

I confirmed that it's indeed due to this, as the memory comes back to normal after a while. However, for our library we often need to process a lot of requests/second, so after a while the board crashes. I read that this 'issue' with the TCP protocol is solved by the ESP8266WebServer library, so how to actually do it for a generic code using the WiFiServer library? Thanks!

@igrr
Copy link
Member

igrr commented Jul 27, 2016

FYI, @me-no-dev did a modification to LwIP stack, now the number of connections kept in TIME_WAIT state is limited. So the memory "loss" should by limited by MEMP_NUM_TCP_PCB_TIME_WAIT * 184, and MEMP_NUM_TCP_PCB_TIME_WAIT is set to 5 in lwipopts.h. For now, this change is available in git version only.

Regarding ESP8266WebServer, the trick is to ask the client to close the connection instead of closing it on the ESP. In TCP, the party which does "active close" has to keep the connection for a long time, while the other party doesn't have to. ESP8266WebServer sends "Connection: close" header to the client, and then waits until client closes the connection.

@xiaoli
Copy link

xiaoli commented Nov 15, 2016

Thanks for the changes of LwIP stack #2260 made by @me-no-dev

@CircuitSerialKiller
Copy link

Yes! Thanks so much for adding this @me-no-dev!!
Under no circumstances should it be acceptable to have any code that just lets the ESP8266 crash.
Hopefully we can get a stable version on github soon... I noticed something was changed after 2.3.0 that easily makes the heap run out and TCP send fails with higher latency connections:
(Issue 2925).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants