-->
Page 1 of 2

Memory leak with the function wget()

PostPosted: Wed Feb 17, 2016 8:36 am
by cicciocb
Hi Mmiscool,
I'm just playing around with your latest version (1.81) and I discovered that, each time the wget() function is called, there are around 200 bytes of memory gone; this cause the ESP to crash after a while.
Looking inside your code, I discovered that the problem comes from the function FetchWebUrl() that, in turns, calls the function client.connect(), where the leak is generated.
Searching on internet, I discovered that there is a patch available on the framework; in particular the file "ClientContext.h" in the framework needs to be patched as below :
Code: Select allline 64 err = tcp_close(_pcb);
line 65 tcp_abort(_pcb); // that line needs to be included //
line 66 if(err != ERR_OK) {
line 67 DEBUGV(":tc err %d\r\n", err);
line 68 tcp_abort(_pcb);
line 69 err = ERR_ABRT;


That file is located at :
C:\Documents and Settings\YOUR_NAME\Application Data\Arduino15\packages\esp8266\hardware\esp8266\2.0.0-rc1\libraries\ESP8266WiFi\src\include

You can find all the details here :
http://www.esp8266.com/viewtopic.php?f=28&t=3003&start=8

Hope you can include this into your next version.

Regards,
Cicciocb

Re: Memory leak with the function wget()

PostPosted: Wed Feb 17, 2016 9:52 pm
by Mmiscool
just tried this. still seem to have the same problem. hmmm

Re: Memory leak with the function wget()

PostPosted: Thu Feb 18, 2016 3:23 pm
by cicciocb
Strange as it works for me!

Re: Memory leak with the function wget()

PostPosted: Wed Apr 06, 2016 4:45 pm
by psc-esp8266
To me it seems this bug is still present at version Basic 2.0.Alpha 7
I have done some logging (1 call per minute) and quite constantly each wget call waists between 240-258 byte of memory.
It crashes the unit after 12 calls (or when freeram() memory drops below 15600).
Can anybody confirm this bug is considered to be fixed? If so I might look into the command I used:
let OPString = "api.thingspeak.com/update?api_key=xxxxxxxxxxx&field1=" & t & s & u & DevID & "&field5=" & Uptime
let w = wget(OPString)