Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Wi-Fi Combo Forum Discussions

ClMa_3563786
Level 2
Level 2

Hello,

I have a question about dynamoc memory usage for HTTP/HTTPS.

I'm using FreeRTOS and LwIP stack.

I am connected to an HTTPS server. I notice almost 40KB of memory is allocated in runtime as follow:

http_client_init() : ~10KB

http_client_connect : ~10KB

Defragmented buffer: ~16KB

I'm looking for advices on defines or configuration that might be tweaked for reduce this memory allocation ?

Thanks for your recommandations

0 Likes
4 Replies
PriyaM_16
Moderator
Moderator 250 likes received 100 likes received 50 likes received
Moderator

By dynamic memory, I am assuming you are pointing to the heap size. I tried to monitor the allocated and free heap(using mallinfo provided in WICED) for httpbin_org application and the results are as below:

Before WICED init:

-----------------------------------------------------------------------

sbrk heap size:    1708520

sbrk current free: 1695736

malloc allocated:     9264

malloc free:          3520

total free memory: 1699256

-----------------------------------------------------------------------

Starting WICED vWiced_006.000.001.0005

Platform CYW943907AEVAL1F initialised

Started FreeRTOS v9.0.0

Initialising LwIP v2.0.2

DHCP CLIENT hostname WICED IP

WWD interface initializing with US/0

WLAN MAC Address : 44:91:60:28:5C:2A

WLAN Firmware    : wl0: Nov 24 2017 00:13:08 version 7.15.168.102 (r677543) FWID 01-c41dd43a

WLAN CLM         : API: 12.2 Data: 9.10.74 Compiler: 1.31.3 ClmImport: 1.36.3 Creation: 2017-11-24 00:08:47

Init took ~180 ms

Joining : riya123

Successfully joined : riya123

Setting IPv6 link-local address

Obtaining IPv4 address via DHCP

IPv6 Network ready IP: FE80::4691:60FF:FE28:5C2A

IPv4 Network ready IP: 192.168.43.209

Resolving IP address of www.httpbin.org

www.httpbin.org is at 52.4.95.48

Connecting to www.httpbin.org

Connected

At the end of application:

-----------------------------------------------------------------------

sbrk heap size:    1708520

sbrk current free: 1650680

malloc allocated:    50224

malloc free:          7616

total free memory: 1658296

-----------------------------------------------------------------------

AxLi_1746341
Level 7
10 comments on KBA 5 comments on KBA First comment on KBA
Level 7

riya wrote:

Before WICED init:

-----------------------------------------------------------------------

sbrk heap size:    1708520

sbrk current free: 1695736

malloc allocated:     9264

malloc free:          3520

total free memory: 1699256

-----------------------------------------------------------------------

At the end of application:

-----------------------------------------------------------------------

sbrk heap size:    1708520

sbrk current free: 1650680

malloc allocated:    50224

malloc free:          7616

total free memory: 1658296

-----------------------------------------------------------------------

Can you explain a bit about above numbers?

By checking total free memory:

1699256 - 1658296 = 40960

So you lost about 40KB memory at the end of application? Isn't it a leak?

0 Likes
ClMa_3563786
Level 2
Level 2

OK, we have the same numbers.


Do you know any way to reduce this amount of memory used?

Any defines to tweak ?

0 Likes
PriyaM_16
Moderator
Moderator 250 likes received 100 likes received 50 likes received
Moderator

Hello,

You may try to reduce the memory footprint by removing the libraries that your application doesn't require. Please have a look at these threads which address a similar issue: