# Problems with freeing allocated memory (freeRTOS v.8.0)

**URL:** <https://forums.freertos.org/t/problems-with-freeing-allocated-memory-freertos-v-8-0/1068>\
**Category:** Kernel\
**Created:** [August 29, 2014, 3:08pm UTC](https://forums.freertos.org/t/problems-with-freeing-allocated-memory-freertos-v-8-0/1068 "2014-08-29T15:08:48Z")\
**Posts on this page:** 2\
**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 29, 2014, 3:08pm UTC](https://forums.freertos.org/t/problems-with-freeing-allocated-memory-freertos-v-8-0/1068/1 "2014-08-29T15:08:48Z")

</div>

**[kudl4t4](https://sourceforge.net/u/kudl4t4/)** wrote on [Friday, August 29, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/2fc799ff/#f00b):

**My code looks like**

```auto
/*------ VARIABLES ------*/
uint8_t how;
typedef struct {
  uint8_t *nfcid;
} Test;

typedef union {
  Test here;
} Haha;

Haha *haha;

/*------ FUNCTIONS ------*/
void memoryAlloc( Haha **haha ) {
  Haha *h =(Haha *)pvPortMalloc( (1) * sizeof(Haha) );
  *haha = h;

  uint8_t *r =(uint8_t *)pvPortMalloc( (1) * sizeof(uint8_t) );
  *r = 0x0F+how;
  (*haha)->here.nfcid = r;
}

void freeAlloc( Haha *haha ) {
  vPortFree(haha->tutaj.nfcid);
  vPortFree(haha);
}

/*------ MAIN ------*/
void main() {
  how++;
  memoryAlloc(&haha);
  freeAlloc(haha);
}

```

**and it seems like vPortFree doesn’t free memory. What may be the problem?**

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [August 29, 2014, 4:27pm UTC](https://forums.freertos.org/t/problems-with-freeing-allocated-memory-freertos-v-8-0/1068/2 "2014-08-29T16:27:50Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Friday, August 29, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/2fc799ff/#3ef8):

Your use of pointers to pointers is too mind bending for me to be able to work it out, and I don’t know where tutaj came from at all. Try creating a dummy application is something like MingW that runs the code with normal C lib mallocs and frees then step the code to see what it’s doing.
