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

Printing Stack and Heap pointers

Hi everyone,

I am facing memory leak issues while using nrf52 iot SDK for MQTT. The application has a high RAM usage and I am running into memory leakage issue where program starts behaving abnormally after running for few times. Could anyone please help me in printing the stack and heap pointers so that I can figure where exactly when they go out of bounds?

Thanks

Parents
  • Hi Jawad,

    a quick-and-dirty way of obtaining the value of the stack pointer is to push a variable to the stack and then print the address of said variable, i.e.

    void print_stack_pointer() 
    {
      uint32_t * ptr = NULL;
      NRF_LOG_INFO("%p \n", (uint32_t)&ptr);
    }
    

    I am not sure if you can use the same approach to get the current heap pointer , but I thought that you were'nt using the heap since this is related to this and this question.

Reply
  • Hi Jawad,

    a quick-and-dirty way of obtaining the value of the stack pointer is to push a variable to the stack and then print the address of said variable, i.e.

    void print_stack_pointer() 
    {
      uint32_t * ptr = NULL;
      NRF_LOG_INFO("%p \n", (uint32_t)&ptr);
    }
    

    I am not sure if you can use the same approach to get the current heap pointer , but I thought that you were'nt using the heap since this is related to this and this question.

Children
Related