How to configure Project Heap & TCP Heap in MHC3 Projects

How to configure Project Heap & TCP Heap in MHC3 Projects

Postby manolisss » Tue Apr 05, 2022 8:32 am


We are still trying to get clear guidelines on how to configure the project heap but it is not clear from Microchip's documentation.
It was previously mentioned in this thread, that the TCP heap comes out of the Project heap. Does this mean that when setting the Project heap at 70k and TCP heap at 60k, only 10k is left for rest of the project? It doesn't seem to make much sense...

Also, we have noticed that in a project with 165k free Data Memory, if we increase the Project heap at 100k and the TCP heap at 70k, then the project becomes stuck shortly after loading. Does this mean that the sum of the two heap settings needs to be less than the total free Data Memory? If we set the heaps back to 70k/60k then the same project works normally.

Any clarification on this issue would be greatly appreciated.
Posts: 1
Joined: Tue Apr 05, 2022 8:28 am
PIC experience: Professional 2-5 years with MCHP products

Re: How to configure Project Heap & TCP Heap in MHC3 Project

Postby AussieSusan » Wed Apr 06, 2022 3:39 am

I'm not quite sure what you ean by ', doesn't make sense'. As far as the linker is concerned (and that is the thing that sets up the heap space) the proram heap is whatever you tell it to be.
The application that is running can use that heap however it likes so the TCP code looks like it is requested its space from the overall heap. If it needs 60 K and the heap is 70K then yes, you will have 10K left over.
However the heap is only used for dynamically allocated memory and that is rarely used on smaller MCUS (and you don't mention which one you are using) because of the issues many of the algorithms have in fragmenting the heap space if they are not properly written. On a device that is supposed to 'run forever' (which is what most embedded systems are for) then fragmenting the heap is a sure way to die at some time when the memory cannot be allocated but your code (typically) doesn't check for and starts to write over random memory locations.
Therefore 10K of heap left over is often more than enough.
Of course this all depends on the application and how it is written.
Verified identity
Posts: 162
Joined: Mon Jun 16, 2014 4:45 am
PIC experience: Experienced Hobbyist

Return to PIC32 topics

Who is online

Users browsing this forum: No registered users and 1 guest