CPP object in new task function memory leak
Posted: Sat Jul 01, 2017 4:05 am
I'm using ESP-IDF release v2.1 (rc) with CPP code.
When I create a new TASK and use CPP objects like this then exit the task code I get a memory leak:
This DOES NOT leak memory:
And this work around DOES NOT leak memory:
Is this expected behavior? Am I the only one getting this problem?
Every time I create a new task, I was getting a massive memory leak and later I found out it was caused by this weird behavior.
When I create a new TASK and use CPP objects like this then exit the task code I get a memory leak:
Code: Select all
void vATaskFunction( void *pvParameters )
{
string s = "hello";
vector<int> v;
vTaskDelete(NULL);
}
Code: Select all
void vATaskFunction( void *pvParameters )
{
string* s = new string("hello");
vector<int>* v = new vector<int>();
delete s;
delete v;
vTaskDelete(NULL);
}
Code: Select all
void helper( void *pvParameters )
{
string s = "hello";
vector<int> v;
}
void vATaskFunction( void *pvParameters )
{
helper(pvParameters);
vTaskDelete(NULL);
}
Every time I create a new task, I was getting a massive memory leak and later I found out it was caused by this weird behavior.