“Is configTOTAL_HEAP_SIZE only for the RTOS and the size in the linker script for everything else?”
Effectively yes. configTOTAL_HEAP_SIZE is used if pvPortMalloc() is called. The heap set by the linker script is used if malloc() is called. The RTOS only uses pvPortMalloc(). Application code and drivers might use one or both.
“I am using heap.4”
heap_3.c is the only provided memory manager that uses malloc(). Heap_1, 2 and 4 uses configTOTAL_HEAP_SIZE.
“2) I understand the Stack size in the linker script is only used by main before the scheduler starts.”
Some ports also use that stack as the interrupt stack.
“ I know each task has its own stack, Does that allocation for these stacks come out the memory defined by configTOTAL_HEAP_SIZE ?
“3) I am using lwIP in my application and it uses malloc and free as defined in mem.h. Should I use pvPortMalloc and pvPortFree instead? The lwIP example I based my app off of came from NXP and used FreeRTOS so I dont understand why it wouldnt already use pvPortMalloc and pvPortFree.”