#80 Single malloc region for queues


Right now, xQueueGenericCreate calls pvPortMalloc to allocate a Queue_t, then calls it again to allocate the storage space for the queue data. If you have a lot of semaphores, this means a lot of calls to pvPortMalloc all asking for one-byte heap blocks, which will waste quite a bit of space on heap metadata! It would be more efficient (both in RAM space and time) to pack the Queue_t and its data area into a single heap allocation, of size (sizeof(Queue_t)+uxQueueLength*uxItemSize+1), and have the data area live immediately after the Queue_t in RAM (even for actual data queues, this shouldn’t hurt things). This cannot cause any alignment problems because the queue data area is only ever touched by memcpy, which has no alignment requirements.

Originally discussed at https://sourceforge.net/p/freertos/discussion/382005/thread/68357f7e/.


  • Richard Barry

    Richard Barry - 2014-12-27
    • status: open --> closed
  • Richard Barry

    Richard Barry - 2014-12-27

    Implemented in V8.2.0 (available as a release candidate at the time of writing).


Log in to post a comment.