This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS Stack monitoring (possibly a SYSBIOS question?)

Other Parts Discussed in Thread: SYSBIOS

Champs,

I hazard posting this here; because it's almost more of an RTOS question; BUT, the simple link RTOS is a little different... so...

Does anyone know of a way to monitor the heap utilization for the SYSBIOS RTOS in realtime?  For the BLE stack, there's a really cool way enable some debug and you can see what the stack is doing; but I am trying to do the same for the SYSBIOS heap?  Normally, I would have used something like HeapMem_getStats- which would be fine, except the prototype for that call is:

HeapMem_getStats((HeapMem_Handle)heapMemStruct, *xdc_runtime_Memory_Stats);

Again, this is fine, but, what is the name of the heapMemStruct for the SYSBIOS heap?  Or, if there's some other magic way to do this; please advise; all I'm trying to do is output the amount of free memory still available on the heap every few seconds so I can look for leaks.

  • Hi,

    From the appBLE.cfg RTOS config file:

    var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');

    This is where the RTOS heap is allocated.

    Best wishes
  • Hi Dave,

    You might get more help in the TI RTOS forums but I will give it a try :)

    The memory manager is a proxy for the selected heap and you can use the Memory_ API's directly.

    As long as the Memory allocation calls (Memory_alloc/Memory_free) is used with NULL as heap argument then the default heap is used. I haven't tested myself but I guess it can be found the following way:

    #include <xdc/runtime/Memory.h>
    
    extern const IHeap_Handle Memory_defaultHeapInstance;
    Memory_Stats stats;
    Memory_getStats(Memory_defaultHeapInstance, &stats);
    

    More info: <tirtos_path/docs/docs_overview.html> -> TI-RTOS Kernel Runtime APIs and Configuration (cdoc) -> package xdc.runtime; -> module Memory

    Regards,
    Svend

  • Svend,
    Thanks- so I initially had some trouble with this; but I think in the end can only assume it was pilot error; and this does indeed work. For the record; you DON'T need (want? the compiler yelled at me about it) the extern const IHeap_Handle Memory_defaultHeapInstance; line; it seems the symbols is "just there" somehow without this; but the call to Memory_getStats with the handle Memory_defaultHeapInstance works great.

    Thanks!