This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Reset Heap & malloc/free

Hi there,

Is there a way to re-initialize the whole heap region? It should also reset "internal pointer" of the malloc method. I use malloc/free in only one task and I want to start/stop this task. This should prevent memory leaks.

Chip: Cortex M3, LPC1788

Thx, Frederic

Parents
  • "If you don't manage to free memory in exactly the reverse order that it was allocated, you might end up in a fragmented memory and after n times you might fail to allocate enough contiguous memory." Is this statement absolutely true? There are some embedded applications build around very complex SW architectures and they just can't get away with using malloc/free. So, an statement like this may bring down everything. I'm talking about the work made by many engineers over years of work, it would all fall apart if this statement is true.
    Is there anybody from ARM who could assist in this thread?
    We're working on a case where free/malloc result in data aborts. We've traced the code up the moment when free is called. We can capture the memory state in that moments and see that the pointers exist and the data pointed is in the right place, everything seems ok, there'r no other pieces of code running, tasks are locked in RL so they can't interrupt, yet the next instruction (free(pointer)) results in a data abort exception.

Reply
  • "If you don't manage to free memory in exactly the reverse order that it was allocated, you might end up in a fragmented memory and after n times you might fail to allocate enough contiguous memory." Is this statement absolutely true? There are some embedded applications build around very complex SW architectures and they just can't get away with using malloc/free. So, an statement like this may bring down everything. I'm talking about the work made by many engineers over years of work, it would all fall apart if this statement is true.
    Is there anybody from ARM who could assist in this thread?
    We're working on a case where free/malloc result in data aborts. We've traced the code up the moment when free is called. We can capture the memory state in that moments and see that the pointers exist and the data pointed is in the right place, everything seems ok, there'r no other pieces of code running, tasks are locked in RL so they can't interrupt, yet the next instruction (free(pointer)) results in a data abort exception.

Children
No data