Direct using pvPortMalloc() and vPortFree()

znatok wrote on Sunday, November 10, 2013:

Hi,
In my application I need some malloc/free mechanism. Considering that FreeRTOS already has pvPortMalloc() and vPortFree() I plan to use this functions instead of invoacation of the standard library. I have a few questions regarding this:

  1. Is it generally OK to use FreeRTOS for heap management not only related to FreeRTOS resources.
  2. Are this functions thread safe?
  3. I’m currently using heap_2. I’ve read about fragmentation problem so I plan to pass to heap_4 unless heap_2 has best match allocation? I mean if I’m going to allocate and free blocks of let’s say 100 and 50 bytes in random order am I going to end up with memory luck for 100 bytes block (as all memory will be 50 bytes fragmented)?

Thanks.

rtel wrote on Sunday, November 10, 2013:

Yes it is fine to use pvPortMalloc() and vPortFree() in the application.

Yes they are thread safe.

Best to use heap_4.c

Regards.