Hi FreeRTOS forums experts,
Recently I migrated my project from FreeRTOS V8 to FreeRTOS V10. I started to have this problem vPortFree() does not free the allocated buffer. It is so annoying that my application is getting the HardFault and I cannot be able to solve this issue. Can anyone please point out some suggestions so that I can fix my issue?
OR
If anyone has migrated from FreeRTOS v8 to V10, please point out the points which I need to take care of. Please it is a kind request as I’m not getting any suggestions.
which memory manager are you using?
Hi RAc,
heap_4.c is the file I’m using for.
Could you please be a little bit more informative? What is your target and your toolset (edit: apparently IAR)? What exactly do you see happening? Do you get a hard fault while executing vPortFree(), or what happens exactly? Have you checked your stack sizes?
Those are all the questions you would ask yourself if somebody else presented you that report, so if you want a fast answer, it would be wise to provide all of that information beforehand.
Hi RAc,
First, we have a working project it was running on FreeRTOS V8 then we decided to migrate
project to CC3235(the previous project was on CC3200).
Our target is to migrate the current simplelink drivers run on FreeRTOS V10, in CC3235SF. I have solved the HardFault issue by adjusting the Stack Size.
The current issue is if I allocate memory using malloc and then try to free using free(). What I found is buffer/pointer is not getting cleared. I use the free function to deallocate the memory but for cross-checking, I have freed the memory and then copied it into the buffer. How is this possible that after freeing the memory content is still there.
after stating the scheduler I have used these demo lines of code to our project to make sure this works but I can see that it is unable to free the memory. Find the dummy code there.
int* ptr;
int n = 5, i;
int arr[5];
ptr = (int*)malloc(n * sizeof(int));
for (i = 0; i < n; ++i)
{
ptr[i] = i + 1;
}
free(ptr);
for (i = 0; i < n; ++i)
arr[i] = ptr[I];
Pardon me for asking this silly question as I’m new to the RTOS community and I don’t know much. So please kindly point it out my issues or I 'm not clear.
IDE used is IAR
This is illegal code. After freeing the memory, you can’t touch it. Anything that looks like it works may or may not work by pure coincidence. Also, do I understand it correctly that you expect memory to be zeroed out during free()? That’s not the case.
I know that is Illegal code but it still has the data. My question is after freeing the data why it has the data which I have assigned earlier.
Why shouldn’t it? It’s unpredictable what is in it after you freed it. Again, free() does not necessarily change anything in the area, so there is nothing unexpected in it being unmodified. Some other task may (or may not) have gotten the memory in between and then may or may not have written something to it. What makes you think that it shouldn’t contain whatever you expect? What exactly do you expect to see in it?