Hello All,
I am running my application on Marvell MW300 board, using FreeRTOS V9.0.0.
In my application when I try to connect HTTPS server, mbedtls shows error.
[wm_mbedtls] ssl_tls.c:5431: |1| 0x00121188: alloc(4429 in bytes) (4429 out bytes) failed.
While debugging it is observer that this is due to the shortage of heap memory. Here is the heap memory stat
Heap size ---------------------- : 305536
Free size ---------------------- : 17888
Peak Heap Usage since bootup --- : 291048
Total allocations -------------- : 136
Failed allocations ------------- : 0
Min overhead per allocation ---- : 16
Biggest free block available now : 8040
I print this heap memory info before try to connect my HTTPS server.
It is observed that when a device trying to connect HTTPS server, mbedtls want to allocate two 4429 byte buffer (in and out), but it gets failed because of Biggest free block available is 8040
Here is the code of mbedtls.
/*
* Prepare base structures
*/
if( ( ssl-> in_buf = mbedtls_calloc( 1, MBEDTLS_SSL_IN_BUFFER_LEN( ssl->conf ) ) ) == NULL ||
( ssl->out_buf = mbedtls_calloc( 1, MBEDTLS_SSL_OUT_BUFFER_LEN( ssl->conf ) ) ) == NULL )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d in bytes) (%d out bytes) failed", MBEDTLS_SSL_IN_BUFFER_LEN( ssl->conf ),
MBEDTLS_SSL_OUT_BUFFER_LEN( ssl->conf ) ) );
mbedtls_free( ssl->in_buf );
ssl->in_buf = NULL;
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
The Free memory available onboard is 17888.
Is it possible to add some “Free memory” into “free blocks available”?
Or any suggestion, how to handle this issue?
I am using the heap 4 scheme.
Thanks in advance.