Why do I need so large mbedtls heap ?! #65093
Replies: 2 comments 4 replies
-
Not quite so extreme, but I was shocked that even increasing to 40000 was not enough for me. Early in the comms process the library allocates an in buffer and an out buffer, each 16713 (MBEDTLS_SSL_IN_BUFFER_LEN) bytes long. Even that seems excess in the embedded world, particularly when there are already tx and rx network buffers in the stack, like CONFIG_NET_BUF_DATA_SIZE. But 40000 wasn't enough, and I noticed there's a lot of dynamic allocation to make copies of the certificates in the chain. Since neither the chain nor the certificate have a clear max, that's easy another 5*4000 bytes that might be required. I guess it's not too much of a stretch to see why you need 100000 with multiple sockets. I had to go to 48000 because I stopped getting alloc failures. I am thankful that every alloc call seems to be checked for failure (unlike the wpa_supplicant driver... grrrr!). So I'm at the point where, even on a purpose built nrf5340 with 512kB of RAM and a dedicated WiFi co-processor, I'm desperately running out of RAM to run a single TLS session over WiFi. |
Beta Was this translation helpful? Give feedback.
-
Hello @hraftery |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello community!
I previously discussed issues to have multiple TLS sockets opened at the same time, that finally conclude the mbedtls heap size was not enough, and increasing
CONFIG_MBEDTLS_HEAP_SIZE
solved my issues so my application was properly working.From 60000 bytes I increased to 100000 bytes !!! Yes you properly read that, almost 100kB to get my application working, while I was doing 2/3 TLS sockets at the same time (only). If not increasing this I was getting ENOMEM error while opening the sockets.
That sound crazy to reserve this amount of memory for this, so I wonder why ? Have you got throw similar issues ? If yes can you share about your experience so that we can discuss of the reasons/solutions/etc around this topic.
Joel
Beta Was this translation helpful? Give feedback.
All reactions