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.

SYSBIOS Heap Handle?

Other Parts Discussed in Thread: SYSBIOS

Champs, so I am 'switching forums' on a question I had originally posted to the LPRF Forum for CC26xx, but really was more of a SYSBIOS question.

What I am trying to do is find an easy way to monitor the heap usage of the SYSBIOS heap during runtime- basically I want to be able to print out the amount of available heap during runtime.  The problem I intrinsically have is that NORMALLY I would do this with a HeapMem_GetStats call if I had created the heap; and I could pass in a handle to the heap that got assigned when I created it.  The problem is; the SYSBIOS heap isn't created that way; it seems to automagically get created using an RTOS config file (it's really a RTSC config file, right?); with this syntax:

From the appBLE.cfg RTOS config file:

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

Okay, so whats the handle of the HeapMem variable?  That is, 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);

but I have no idea what heapMemStruct is (and neither does the compiler!!!).  A colleague from the LPRF group had cited this as a possible option:

#include <xdc/runtime/Memory.h>
extern const IHeap_Handle Memory_defaultHeapInstance;
Memory_Stats stats;
Memory_getStats(Memory_defaultHeapInstance, &stats);
but it doesn't work- when you call getStats it memory faults' cause Memory_defaultHeapInstance, despite compiling fine, seems to have a NULL definition and thus crashes.  So how do I get the amount of available heap memory from the SYSBIOS heap in real time?
  • Hi,I will look into this. What version of SYSBIOS are you running?Judah
  • Hi,
    I did what you suggest above to one of the SYSBIOS examples and it worked fine.
    I didn't do the line: "extern const IHeap_Handle Memory_defaultHeapInstance;"
    but I did everything else and it workd for me.
    Are you sure the fault is caused by the Memory_getStats()?Judah
  • Well, I'm sure it crashed when I call the register read that executes that code; and the register read itself works for all other registers.  I'll try again tomorrow and see if I can set some breakpoints; but I'd still say with 90% confidence, yes it crashes for me.  I too didn't add that line you omitted; because the compiler yelled about it; ut I also didn't get things to work either.

  • Well, this is embarrassing....

    I'm going have to concede I must have typed something wrong; because yes, I will concur it does in fact work.  It's odd; my whole development is on a .git tree; so I don't know where/why things went awry; but this AM I did this and it does work as expected.  About all I can figure is I typed the name of the variable wrong (though oddly to something defined); and that was just the wrong thing to do.  But close this one out as solved; I will also close out the parallel post on the LPRF forum.  

    Thanks!

  • No problem...happens all the time.  Glad you got your problem solved!

    Please mark the thread answered.