Memory Leak/Usage

zaxl
Posts: 29
Joined: Mon Jun 08, 2015 6:34 pm
Contact:

Memory Leak/Usage

Postby zaxl » Thu Jul 23, 2015 4:41 pm

Hi,

I'm using the memory optimized SDK 1.2.0.

The issue is that my tcp disconnect callback is not called and each accepted tcp connection leaks between 108 and 288 bytes.
/Will figure exact number but this is from a timer that runs every second to report free heap/.
Tried to set option REUSEADDR but does not make any difference.
I'm using code based on the esp_httpd .
init ....
espconn_regist_connectcb(&httpdConn, httpdConnectCb);
espconn_tcp_set_max_con_allow(&httpdConn, MAX_CONN);
espconn_set_opt(&httpdConn, ESPCONN_REUSEADDR);
espconn_accept(&httpdConn);

static void ICACHE_FLASH_ATTR httpdConnectCb(void *arg) {
....
....
espconn_regist_recvcb(conn, httpdRecvCb);
espconn_regist_reconcb(conn, httpdReconCb);
espconn_regist_disconcb(conn, httpdDisconCb);
espconn_regist_sentcb(conn, httpdSentCb);

}

I'm closing the connection from my main loop but httpdDisconCb is not called.

The incoming connection limit is a kind of useless - with 2 minutes timewait i can generate enough connections to trigger an out of memory condition. Connect/Close 200 bytes per connection about 100 connections and the device is OOM.
What is the way to deal with TCP memory in general?


Regards
Regards,
zaxl

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: Memory Leak/Usage

Postby ESP_Faye » Mon Aug 03, 2015 10:06 am

Hi,

So sorry for the inconvenience. Could you provide your test code ? We will have a try.

espconn_regist_reconcb(conn, httpdReconCb);
espconn_regist_disconcb(conn, httpdDisconCb);

If the TCP connection broke unexpected, httpdReconCb will be called.
If espconn_disconnect is called or normally TCP disconnect, it will enter httpdDisconCb.

zaxl
Posts: 29
Joined: Mon Jun 08, 2015 6:34 pm
Contact:

Re: Memory Leak/Usage

Postby zaxl » Wed Aug 05, 2015 2:01 pm

Hi,

I'm working on a test case code, i'll give it out when ready.
My code flow is like this:
1. listen on port 80 -> web server
2. outbound ssl connection to server. close connection
3. start normal connection to server - long lived

So far i found out that:
If there is only listen on port 80 -> disconnect callback is called - no leak
If there is outbound connection /don't know which one is causing the problem yet/ -> disconnect callback is not called and it leaks.
Regards,
zaxl

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: Memory Leak/Usage

Postby ESP_Faye » Sun Aug 09, 2015 8:52 am

Hi,

Please have a try with the latest sdk_v1.3.0 http://bbs.espressif.com/viewtopic.php?f=46&t=918&p=3092

If your problem is still unsolved, please provide your test code. We will debug it.

Thanks for your interest in ESP8266!

mharizanov
Posts: 5
Joined: Sun Aug 09, 2015 4:16 am

Re: Memory Leak/Usage

Postby mharizanov » Mon Aug 10, 2015 2:28 pm

I can confirm the exact same: I am running MQTT over TLS and esphttpd over non-TLS connection. As of SDK 1.2 the disconnect callback on non-TLS connections (esphttpd) is broken and if there is a SSL connection active (MQTT in my case). As a result, there is a memory leak introduced. If I run the MQTT client over non-TLS, all work just fine and disconnect callback gets called.
I tried with SDK 1.2 and 1.3 and it fails with both. It works just as expected with SDK 1.1

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: Memory Leak/Usage

Postby ESP_Faye » Mon Aug 10, 2015 4:33 pm

Hi,

So sorry for the inconvenience.

Please update to esp_iot_sdk_v1.3.0 and try the SSL patch here http://bbs.espressif.com/viewtopic.php?f=46&t=925

Please have a try. If your problem is still unsolved, feel free to let us know !

Thanks for your interest in Espressif Systems and ESP8266 !

mharizanov
Posts: 5
Joined: Sun Aug 09, 2015 4:16 am

Re: Memory Leak/Usage

Postby mharizanov » Tue Aug 11, 2015 1:17 am

The patch fixes the issue and all works as expected, thanks!

hdrut
Posts: 25
Joined: Fri Feb 13, 2015 11:02 am
Location: Argentina

SSL example

Postby hdrut » Wed Aug 12, 2015 12:33 am

Hi,

I'm trying to implement the SSL example provided by Espressif, but get the following errors I can't debug:

undefined reference to `espconn_secure_sent'
undefined reference to `espconn_secure_connect'


Any help is appreciated.


Rgds

User avatar
rudi
Posts: 197
Joined: Fri Oct 24, 2014 7:55 pm

Re: SSL example

Postby rudi » Wed Aug 12, 2015 3:15 pm

hdrut wrote:Hi,

I'm trying to implement the SSL example provided by Espressif, but get the following errors I can't debug:

undefined reference to `espconn_secure_sent'
undefined reference to `espconn_secure_connect'


Any help is appreciated.


Rgds



think you simple forget "to add" the ssl lib in makefile?

example:

Code: Select all


LIBS        = c gcc hal phy pp net80211 lwip wpa upgrade main ssl



write please, how you get on in this.

best wishes
rudi ;-)

-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

hdrut
Posts: 25
Joined: Fri Feb 13, 2015 11:02 am
Location: Argentina

Re: SSL example

Postby hdrut » Wed Aug 12, 2015 8:14 pm

Hi Rudi

yes! That was the problem, how silly of me :)

How are you doing? Have you managed to do some progress on copy protection for ESP?

I am now trying SSL communication, just started...



Cheers, i am going to celebrate my birthday today !!

Hope to hear from you soon, wish all is fine with you Rudi, :)

Horacio




rudi wrote:
hdrut wrote:Hi,

I'm trying to implement the SSL example provided by Espressif, but get the following errors I can't debug:

undefined reference to `espconn_secure_sent'
undefined reference to `espconn_secure_connect'


Any help is appreciated.


Rgds



think you simple forget "to add" the ssl lib in makefile?

example:

Code: Select all


LIBS        = c gcc hal phy pp net80211 lwip wpa upgrade main ssl



write please, how you get on in this.

best wishes
rudi ;-)

Who is online

Users browsing this forum: No registered users and 3 guests