# pvPortMalloc() allocates extra bytes

**URL:** <https://forums.freertos.org/t/pvportmalloc-allocates-extra-bytes/1249>\
**Category:** Kernel\
**Created:** [August 25, 2014, 1:03pm UTC](https://forums.freertos.org/t/pvportmalloc-allocates-extra-bytes/1249 "2014-08-25T13:03:37Z")\
**Posts on this page:** 3\
**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:** [August 25, 2014, 1:03pm UTC](https://forums.freertos.org/t/pvportmalloc-allocates-extra-bytes/1249/1 "2014-08-25T13:03:37Z")

</div>

**[chaabanemalki](https://sourceforge.net/u/chaabanemalki/)** wrote on [Monday, August 25, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/3ad21b98/#73bb):

Hello,  
I notice that if I allocate 6 bytes using pvPortMalloc(6), FreeRTOS+Trace shows me that the kernel allocated 16 bytes and not 6, I tried different values but FreeRTOS+Traces always shows me different values than the ones I put in my code and with no pattern between them.

I’m not sure if this is normal or it is freeRTOS+Trace who shows wronge values.

I checked the value passed to pvPortMalloc( size\_t xWantedSize )

and the definition of size\_t is :  
typedef **SIZE\_TYPE** size\_t; /\* type yielded by sizeof \*/

I’m using PIC32, and i’m not sure if size\_t will be considered as int32 or int8.

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [August 25, 2014, 2:06pm UTC](https://forums.freertos.org/t/pvportmalloc-allocates-extra-bytes/1249/2 "2014-08-25T14:06:57Z")

</div>

**[bowerymarc](https://sourceforge.net/u/bowerymarc/)** wrote on [Monday, August 25, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/3ad21b98/#73bb/6d6a):

Take a look at the heap code and you’ll understand why there’s a difference.

On Aug 25, 2014, at 9:03 AMEDT, Hicham [chaabanemalki@users.sf.net](mailto:chaabanemalki@users.sf.net) wrote:

> Hello,  
> I notice that if I allocate 6 bytes using pvPortMalloc(6), FreeRTOS+Trace shows me that the kernel allocated 16 bytes and not 6, I tried different values but FreeRTOS+Traces always shows me different values than the ones I put in my code and with no pattern between them.
> 
> I’m not sure if this is normal or it is freeRTOS+Trace who shows wronge values.
> 
> I checked the value passed to pvPortMalloc( size\_t xWantedSize )
> 
> and the definition of size\_t is :  
> typedef SIZE\_TYPE size\_t; / type yielded by sizeof /
> 
> I’m using PIC32, and i’m not sure if size\_t will be considered as int32 or int8.
> 
> Thank you.
> 
> pvPortMalloc() allocates extra bytes
> 
> Sent from [sourceforge.net](http://sourceforge.net) because you indicated interest in [SourceForge.net: Log In to SourceForge.net](https://sourceforge.net/p/freertos/discussion/382005/)
> 
> To unsubscribe from further messages, please visit [SourceForge.net: Log In to SourceForge.net](https://sourceforge.net/auth/subscriptions/)

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [August 25, 2014, 3:54pm UTC](https://forums.freertos.org/t/pvportmalloc-allocates-extra-bytes/1249/3 "2014-08-25T15:54:05Z")

</div>

**[chaabanemalki](https://sourceforge.net/u/chaabanemalki/)** wrote on [Monday, August 25, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/3ad21b98/#f44a):

```
		/* The wanted size is increased so it can contain a BlockLink_t
		structure in addition to the requested amount of bytes. */

```

got it ;). I should take these 10 extra bytes in consideration when calculating the heap worst case scenario.
