# Queue and  Memory Management functions 

**URL:** <https://forums.freertos.org/t/queue-and-memory-management-functions/1179>\
**Category:** Kernel\
**Created:** [April 11, 2011, 5:56am UTC](https://forums.freertos.org/t/queue-and-memory-management-functions/1179 "2011-04-11T05:56:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 11, 2011, 5:56am UTC](https://forums.freertos.org/t/queue-and-memory-management-functions/1179/1 "2011-04-11T05:56:03Z")

</div>

**[iporboon](https://sourceforge.net/u/iporboon/)** wrote on [Monday, April 11, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/33dc8b65/#21dd):

Hello

I use the queue functions of freertos to pass the messages among the tasks in the real-time systems.&nbsp; My messages are the groups of data&nbsp; such as arrays or structures. I have to create the queues with the message size of array or structure.

It seems to consume a lot of RAM from my systems. I can not send the pointers to the queues because there is not the dynamic mem alloc in freertos API to use to store the arrays or structures, and I do not want to use malloc function from&nbsp; standard C library because of the real-time predictability problem of that function.

Please suggest the solutions of my problem.  
Thank you very much.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [April 11, 2011, 9:43am UTC](https://forums.freertos.org/t/queue-and-memory-management-functions/1179/2 "2011-04-11T09:43:42Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Monday, April 11, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/33dc8b65/#fbff):

Normally, if you are sending large items of data, you would queue a pointer to the data and the application would have to ensure the data was access correctly (only one task has responsibility for changing the data, only one task for marking the buffer free again once the data is read, etc.).

If you want to send different items on a single queue, then the normal way is to send structures on the queue, with one of the structure members indicating what the queued item actually is, so the receiving task knows how to handle the data.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 11, 2011, 1:51pm UTC](https://forums.freertos.org/t/queue-and-memory-management-functions/1179/3 "2011-04-11T13:51:24Z")

</div>

**[iporboon](https://sourceforge.net/u/iporboon/)** wrote on [Monday, April 11, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/33dc8b65/#35a8):

I am very sorry if my problem was not clear.

I can not send the pointers to queue because there is not the dynamic mem alloc in freertos API, so I can not get mem blocks to store the data and I do not want to use malloc function of standard C library because of&nbsp; the real-time predictivity problem of that function.

Best regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 11, 2011, 1:57pm UTC](https://forums.freertos.org/t/queue-and-memory-management-functions/1179/4 "2011-04-11T13:57:32Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Monday, April 11, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/33dc8b65/#cf6f):

If your blocks are always the same size then you can use heap\_2.c as a dynamic memory allocator without fear of fragmentation. Otherwise, can you use statically declared memory blocks?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 11, 2011, 4:06pm UTC](https://forums.freertos.org/t/queue-and-memory-management-functions/1179/5 "2011-04-11T16:06:27Z")

</div>

**[stephencleary](https://sourceforge.net/u/stephencleary/)** wrote on [Monday, April 11, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/33dc8b65/#88e7):

If your blocks are the same size, then you can write a very simple pool allocator.

Otherwise, you can write your own (deterministic) memory allocator. I have implemented a modified version of [TLSF](http://rtportal.upv.es/rtmalloc/), and it works quite well so far.
