I realized that the destructors of the objects that I create locally within a task are not called when the task is eliminated.
I think this happens because the function of the task does not exit properly from its scope, and therefore the destructors of local objects are not called.
How can I solve this problem?
main.cpp
~~~
class MyClass
{
public:
MyClass()
{
buffer = (char*)malloc(5);
}
char* buffer;
//It is never called
~MyClass()
{
delete buffer;
}
};
static void MyTask(void *pvParameters)
{
MyClass my_class = MyClass();
//Delete this task
vTaskDelete(NULL);
}
~~~