We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
To answer your question: Yes. That the idea. Of course the RAM dedicated to the heap will not be 0, but it will be empty. Why not spend some time to find the root cause, i.e the memory leak?
Theoretically, if I manage to free() every malloc(), will the state be the same as after a re-initialization?
The answer to that is it might. It totally depends upon the implementation of malloc() and free(). It might keep the internal list of previous allocations intact and therefore might still be fragmented, thus it might not be able to allocate a large block. We have certainly witnessed some heap allocation strategies that work in this manner.