This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf_malloc function not able to allocate the memory.

Hi everyone

I have been facing some issue while allocating memory using nrf_malloc function on nrf52840.

I am giving  a size parameter of 8 bytes inside the nrf_malloc function.

But the functio

uint8_t* frame_buffer_black = nrf_malloc(8);
 SEGGER_RTT_printf(0,"frame_buffer_black %d\r\n",*frame_buffer_black);
n returns me NULL.

Also the returned value from nrf_mem_reserve function is 0x8108. I am still not able to figure as to what is the meaning if this error.

And also what i need to do in order to be successfull in this stuation.

I have tried increasing the heap and stack size in the project settings, but that also didn't work.

What can i do to resolve this issue

Thanks 

Rajat

Parents Reply
  • Again which SDK version are you using?

    VERIFY_REQUESTED_SIZE(size) macro will return 0x8107 (NRF_ERROR_INVALID_PARAM | NRF_ERROR_MEMORY_MANAGER_ERR_BASE) if the requested size is larger that the largest block size that is set in the memory manager module. 

    #define MAX_MEM_SIZE MEMORY_MANAGER_SMALL_BLOCK_SIZE == 32

    So you must be calling nrf_mem_reserve() with a size larger than 32. 

    The MEMORY_MANAGER_SMALL_BLOCK_SIZE can be set in sdk_config.h

Children
Related