I have made a standalone firmware to test the memory allocation functions on nrf53. i need to use realloc() in a separate application fw and am therefore testing the std c malloc and realloc function. This standalone fw is allocating memory for a string, appending an ascii char onto this string and then looping this process. On each loop memory is reallocated so that there is a free block for the next char. The issue is i set CONFIG_HEAP_MEM_POOL_SIZE=4096 but the program seems to fall over after allocating 1336 Bytes. I have tried switching to k_malloc and creating an equivalent of realloc using k_malloc but this had not fixed the issue either.
I am curious as to why i cannot allocate more memory despite defining a heap size of 4096?
I have tested with other heap sizes too. With 5096 i can allocate 1674, with 6096 i can allocate 2009 and with 7096 set i can allocate 2337.
here is a link to my standalone code.