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.

HeapTrack issue

Other Parts Discussed in Thread: SYSBIOS

Hi everyone,

I have a question about HeapTrack. My sysbios version is 6.34.4.22. I have allocated 4 bytes memory to a heap, then monitor the ROV view and choose the HeapTrack module. There are 4 sheets Basic, HeapAllocList, TaskAllocList and Raw. I select Basic sheet and there are 4 items, address, heapHandle and heapSize are showen in Baisc sheet. Finally, I have seen that the heapSize is shown 0x38, but I just allocate 4 bytes. What dose the heapSize mean?

Ming-Che Lin

  • Hi Ming-Che Lin,

    Please provide below information to help you.

    What is the DSP part number? Have you referred the examples provided by the TI?

    Thanks.

  • Hi Rajasekaran K,

    I am using C6670. I didn't find out any example about HeapTrack Module. Could you provide a example to me?

    Thanks.

     

    Ming-Che Lin

  • Hi Ming-Che Lin,

    Moving this thread to TI-RTOS for correct response.

    Thanks.

  • Ming-Che Lin,

    What's the total size of your heap?  Are you looking at the stats for your default heap?  If so, there could be other allocations happening from that heap.

    Also, can you please post a screen shot of the ROV views you are describing.

    Steve

  • Hi Steve,

    My heap size is 0x1000 and it is not my default heap. I attached the pictures of cfg file and ROV vews for you. As bellow, 4341.HeapTrack.zip.

    Thanks.

    Ming-Che Lin

  • Ming-Che Lin,

    Thanks for posting those screen shots.

    Can you post the screen shots of your "Heap1" heap in the HeapMem view?

    Also, what does the free list look like in ROV for "Heap1"?

    Steve

  • Hi Steve,

    The screen shots are attached as bellow:

    0624.HeapTrack2.zip

    Thanks for your help.

     

    Ming-Che Lin

  • Ming-Che Lin,

    The size you are seeing is the size overhead caused by HeapTrack.

    HeapTrack adds an extra chunk of data to the end of each memory allocation you make.  heapSize is the total size used in the heap you are tracking, plus the size that HeapTrack data.  You can check the size of this extra data with sizeof(HeapTrack_Tracker) in your C code.

    For example, I modified the standard BIOS memory example to use HeapTrack.  After the following allocation:

       IHeap_Handle heap = HeapTrack_Handle_upCast(heapTrack0);

        bufs[0] = Memory_alloc(heap, TASK1BUFSIZE0, 0, NULL); // heap == HeapTrack instance, TASK1BUFSIZE0 == 128

    I saw in the ROV HeapMem view that 152 bytes had been allocated, which is of course larger than the 128 size passed into Memory_alloc.

    I also printed out the size of HeapTrack_Tracker, and it is 24 bytes.

    So, in the HeapTrack view, heapSize = size allocated + sizeof(HeapTrack_Tracker) = 128 + 24 = 152.

    Please refer to the SYS/BIOS User's Guide, section 6.8.4 HeapTrack for more detail.

    Steve

  • Hi Steve,

    Is there any other extra data cased by HeapTrack? I allocated 4 bytes to heap, checked the extra data of HeapTrack_Tracker and it was  24 bytes. In the HeapTrack view, I saw that heapSize was 56 bytes. It was not 24+4 = 28. Attached files are the .c file and .cfg file that I am using. 0636.C and CFG files.zip

    Thanks.

    Ming-Che Lin 

  • Hi Ming-Che Lin,

    Ming-Che Lin said:
    In the HeapTrack view, I saw that heapSize was 56 bytes

    Ok, I have a better understanding of the HeapTrack's 'heapSize' field.  heapSizeis actually a cumulative value!  For each call to alloc (via HeapTrack), it increments heapSize by the amount being allocated.

    Can you check the HeapTrack ROV view again?  Looking under the tab called "HeapAllocList"?  I'm wondering if when you see 56 bytes (0x38), if there are 2 allocations shown?

    I updated the code you sent me and I was able to get the HeapTrack.heapSize equal to 56 bytes using 2 allocation requests of 4 bytes each:

        pu32Test = (Uint32 *)Memory_alloc(heap1, sizeof(Uint32), 1, NULL);
        pu32Test = (Uint32 *)Memory_alloc(heap1, sizeof(Uint32), 1, NULL);

    After stepping over the 2nd Memory_alloc() call, I saw the 56 byte value in ROV for HeapTrack:

    And in the HeapAllocList view, I see the two four byte allocations:

    Also, regarding differences between the size passed in to allocate, and the size that HeapMem actually uses up ...

    HeapMem takes into account the minimum block size and alignment sizes.  If you allocate 4 bytes, then a total of 4 bytes + 24 bytes (HeapTrack header size) is actually needed.

    But, since the minimum block alignment is 8, the size allocated must be a multiple of 8.  28 is not, and so this size gets rounded up to the nearest multiple of 8, which is 32 bytes.

    So, your 4 byte allocation, when used with HeapTrack (due to the extra size needed for the header), will result in a block of size 32 bytes being allocated (since 28 bytes gets rounded up to 32 for HeapMem).

    Lastly, you may now be wondering why HeapTrack is not showing a total size (heapSize) of 64 bytes?

    This is because this rounding up to the nearest multiple of the block size is something that happens internally within the HeapMem module.  HeapTrack doesn't know about that rounding up.

    HeapTrack only knows about the 4 bytes requested, plus the 24 byte HeapTrack header size that's needed.  And so this is why HeapTrack.heapSize only shows 56 bytes (28 * 2) after the second allocation.

    Hope this helps!

    Steve

  • Hi Steve,

    I got it.

    Thanks for your help.

     

    Ming-Che Lin