How calculate heap, stack for PIC32MX

Hi! i have running already my firmware on pic32mx with FreeRTOS, it has 2 serials(printer, usb), 2 I2C(flash, rtc) and 2 SPI (a/c converter) 3 PWMs (calibration, sound) and of course graphics LCD RA8835 with PMP :) Wow! FreeRtos works great! I had it working first as a modules without freertos and now i solve this puzzle with your rtos (semaphores and mutexes are great!)
But… memory… :( can you give me simple tips for calculating heap and maybe stacks? i have tasks created on start of app and never deleted (i am programming measurement device firmware).
I know a little, but info from you, i mean from source :)  are best:)
thanx in advance :)

How calculate heap, stack for PIC32MX

While it is possible to calculate worst case stack usage, likewise heap usage, I take a more pragmatic approach and use experimentation.  It is made easier by the fact that, on the PIC32 (and other CPUs), the FreeRTOS port uses a separate stack for interrupts – so interrupt nesting does not need to be taken into consideration on the task stack. If a stack is too small, then the stack overflow hook will catch it, and you know to increase it.
http://www.freertos.org/Stacks-and-stack-overflow-checking.html If a stack is larger than necessary, then you can resize it using the information obtained from its high water mark.
http://www.freertos.org/uxTaskGetStackHighWaterMark.html With regards to the FreeRTOS heap, if you are allocating everything up front then just inspect the FreeRTOS heap to see how much is left, and you can reduce its size accordingly.  If you are using heap_1.c or heap_2.c there is even a function provided to query how much is left (xPortGetFreeHeapSize()). Regards.

How calculate heap, stack for PIC32MX

Thanx a lot! As always support here is the greatest!
Thanx!