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

Memory Manager Diagnostics doesn't work

Hi,

We are working with SDK v14.1 and are trying to debug some memory issues by enabling MEM_MANAGER_ENABLE_DIAGNOSTICS.

In memory_manager.c in function print_block_info() the macro NRF_LOG_BYTES_DEBUG is used to print the status of the memory blocks. This macro however isn't defined anywhere, seems like the log module doesn't implement it.

We tried to replace this macro by various variants of NRF_LOG_DEBUG, but it seems (also according to its definition), that this macro only allows to print strings that are defined during compile time (const). Any run time-defined strings in functions can't be printed, since their pointer becomes invalid after the function returns.

We solved the problem by changing the print_buffer array in function print_block_info() to static, to keep the pointer valid. Since the print_block_info() is called 7 times after another for all types of memory block size, print_buffer had to be changed to a two dimensional array.

This however consumes 7*80=560 bytes of RAM, essentially wasting memory, so we were wondering if there was an easier solution to this issue.

Thanks, Carl

Parents Reply Children
  • Hi Jianxuan,

    You could try to replace NRF_LOG_BYTES_DEBUG with NRF_LOG_INFO_ARRAY, where you implement NRF_LOG_INFO_ARRAY as:

    void NRF_LOG_INFO_ARRAY(uint8_t * array, uint8_t array_size)
    {
        for(int i = 0; i < array_size; i++)
        {
            NRF_LOG_RAW_INFO("0x%x ",array[i]);
        }
        NRF_LOG_RAW_INFO("\r\n");
    }

    You could also test Daniel Sullivan's solution (see the code he posted).

    And you could also try NRF_LOG_HEXDUMP_INFO().

Related