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.

How to config XDC to use other than HeapStd as default heap?

Other Parts Discussed in Thread: OMAPL138

I have code I want to benchmark on my OMAPL138 DSP and it uses normal C "new" etc...

I have succeeded in first attempt using what apparently is the default heap implementation HeapStd, now I want to try other sys/bios heaps starting with HeapMem to compare performance...

Working with my cfg file using xgconf I created a new default heap instance as:

BIOS.heapSize = 0;

var heapMem0Params = new HeapMem.Params();
heapMem0Params.instance.name = "heapMem0";
heapMem0Params.size = 6291456;
heapMem0Params.sectionName = ".heap";
Program.global.heapMem0 = HeapMem.create(heapMem0Params);
Memory.defaultHeapInstance = Program.global.heapMem0;
Memory.defaultHeapSize = 6291456;

However when I compile I get:

Description    Resource    Path    Location    Type
xdc.runtime.HeapStd.Instance#0 : The RTS heap (Program.heap = 0) is used up.    .xdchelp    /DSP    53    C/C++ Problem

When I try to set value to Program.heap=2048, the tool always resets it to 0 and gives me the same error...

What is the proper way to set up a new default heap impl statically using the cfg file/xgconf?

  • Can you tell me what version of BIOS you are using?

    HeapMem should be the default.  Replace the "BIOS.heapSize = 0" with specifying the size you want.

    Judah

  • 6.33.5.46

    The docs said "HeapStd" was the default...if it is HeapMem, I want to move on to HeapMultiBuf...

  • Yes, HeapMem should definitely by the default for that release.  You can confirm it by looking at your generated *.map file.

  • Well I set BIOS.heapSize = 6291456, the same as my created HeapMem instance and did a rebuild...the error msg went away but when I try to run an emulator debug session it never gets to break at main but hangs somewhere with no error msgs...

    Here's my .cfg file, any ideas?

    Tried to upload my .map file as well but the forum tool wouldn't allow it!

    Also, can you explain the difference between Program.heap, BIOS.heap and Memory.defaultHeapSize?

    6835.app.cfg

  • Kent,

    When you do BIOS.heapSize = xxx, it creates a HeapMem with that size already.

    If you are going to set the Memory.defaultHeapInstance, then don't set the BIOS.heapSize

    Judah

  • Something not right is happening here. I've configured a HeapMultiBuf as my "default heap" using:

    var heapMultiBuf0Params = new HeapMultiBuf.Params();
    heapMultiBuf0Params.instance.name = "heapMultiBuf0";
    heapMultiBuf0Params.blockBorrow = true;
    heapMultiBuf0Params.numBufs = 3;

    // Create the parameter structures for each of the three
    // HeapBufs to be managed by the HeapMultiBuf instance.
    heapMultiBuf0Params.bufParams.$add(new HeapBuf.Params());
    heapMultiBuf0Params.bufParams[0].blockSize = 64;
    heapMultiBuf0Params.bufParams[0].numBlocks = 1000;
    heapMultiBuf0Params.bufParams[0].sectionName = ".heap";

    heapMultiBuf0Params.bufParams.$add(new HeapBuf.Params());
    heapMultiBuf0Params.bufParams[1].blockSize = 128;
    heapMultiBuf0Params.bufParams[1].numBlocks = 200;
    heapMultiBuf0Params.bufParams[1].sectionName = ".heap";

    heapMultiBuf0Params.bufParams.$add(new HeapBuf.Params());
    heapMultiBuf0Params.bufParams[2].blockSize = 256;
    heapMultiBuf0Params.bufParams[2].numBlocks = 100;
    heapMultiBuf0Params.bufParams[2].sectionName = ".heap";

    Program.global.heapMultiBuf0 = HeapMultiBuf.create(heapMultiBuf0Params);

    Memory.defaultHeapInstance = Program.global.heapMultiBuf0;
    Memory.defaultHeapSize = 0;

    I then try to use it in my app using "new" and "delete" calls and the memory stats do not change:

        Memory_Stats ms;
        Memory_getStats( Memory_defaultHeapInstance, &ms );

        printf("TotalFreeSize = %u  TotalSize = %u, LargestFreeSize = %u\n", ms.totalFreeSize, ms.totalSize, ms.largestFreeSize  );

        void *pMem = new int[20];

        Memory_getStats( Memory_defaultHeapInstance, &ms );

        printf("TotalFreeSize = %u  TotalSize = %u, LargestFreeSize = %u\n", ms.totalFreeSize, ms.totalSize, ms.largestFreeSize  );

        delete[] pMem;

        Memory_getStats( Memory_defaultHeapInstance, &ms );

        printf("TotalFreeSize = %u  TotalSize = %u, LargestFreeSize = %u\n", ms.totalFreeSize, ms.totalSize, ms.largestFreeSize  );

    results in:

    TotalFreeSize = 115200  TotalSize = 115200, LargestFreeSize = 256
    TotalFreeSize = 115200  TotalSize = 115200, LargestFreeSize = 256
    TotalFreeSize = 115200  TotalSize = 115200, LargestFreeSize = 256

    Whereas if I use Memory_alloc() and Memory_free() it works:

    TotalFreeSize = 115072  TotalSize = 115200, LargestFreeSize = 256
    TotalFreeSize = 115200  TotalSize = 115200, LargestFreeSize = 256

    I'm trying to get new and delete to use this heap...what am I doing wrong?






  • Kent,

    Can you please remove the following line and see if it makes a difference:

        Memory.defaultHeapSize = 0;

    We think that this line is causing your HeapMultiBuf to not be plugged in as the default heap.

    Just wondering but for your Memory_alloc() calls, are you calling it passing the HeapMultiBuf handle or are you passing in NULL as the handle?

    You should be able to pass in NULL as the handle and it should use your default Heap instance.

    Judah

  • Didnt make any difference, same results...

    I stated that the Memory_alloc() calls work, its new/delete that dont, the new succeeds but I dont know where the heap is its allocating from and why it isnt using Memory_defaultHeapInstance.

    I can use Memory_defaultHeapInstance or 0 they both work...

  • Kent,

    I just took your code that you've posted both in the .cfg file and .c file and it works for me fine using BIOS 6.33.05.46.

    Is there anything else that you might be going on?  Can you determine what memory you are getting from the new call?

    Then also attach your *.map file, that should tell where its getting the memory for the new.

    I've attached here my project just in case you wanted to take a look at it.

    4810.bigtimecplusplus.zip

    Judah