Nordic - nRF9160 (nRF Zephyr SDK) - Is __heapstats() Supported? When will it be supported if not?

Hello,

Are there plans to support the ARM function __heapstats() for the nRF9160 (under Zephyr)?

I see since 1.9.x sys_heap_runtime_stats_get() is supported - but when I try to compile under 1.9.1 it says I'm trying to redefine the function and/or 


struct sys_heap_runtime_stats stat; -> sizeof stat Is undefined or unknown.

Are there working examples of either of these two functions someplace for the nRF9160 under Zephyr?

I have the following in my source:

#include <sys/sys_heap.h>


#define CONFIG_SYS_HEAP_RUNTIME_STATS

I see also from the pull request logs for Zephyr on github this was done (adding the sys_heap stats) in the Fall of 2021.

Thanks,
John W.

Parents Reply
  • Hi John, 

    Not sure if this is something of use to you but I will put it here for others facing this issue in the future. 

    I have had luck with the following:

    proj.conf:

    CONFIG_SYS_HEAP_RUNTIME_STATS=y

    c function:

    #include <zephyr/sys/sys_heap.h>

    // Debug Variables
    extern struct k_heap _system_heap;
    struct sys_memory_stats stats;
    void rtos_hal_print_heap_info(void
    {
        sys_heap_runtime_stats_get(&_system_heap.heap, &stats);

        printk("\n");
        printk("INFO: Allocated Heap = %zu\n", stats.allocated_bytes);
        printk("INFO: Free Heap = %zu\n", stats.free_bytes);
        printk("INFO: Max Allocated Heap = %zu\n", stats.max_allocated_bytes);
        printk("\n");

        return;
    }
    Kind Regards, 
    Jaden 
Children
Related