I have a method that returns a new map pointer which is later consumed. Where the map is consumed I have the following code:
void Updater::set_data(map<string, string> * data)
{
if (this->data != NULL)
{
delete this->data;
}
this->data = data;
}
This consumer is running as long as the application is running.
However, my application is leaking memory and Valgrind is reporting that it's leaking (600 (48 direct, 552 indirect) bytes in 1 blocks are definately lost in loss record ...) at the line that constructs the map:
map<string, string> * values = new map<string, string>();
Am I doing something wrong to get rid of the map (and free the memory)? I don't have much C++ experience, so I'm guessing this is some beginners mistake, but I've spend the larger amount of a day trying to figure what it could be.
EDIT I have only 2 updaters running (or 1 if I chose so, but always predefined fixed amount) and the map always contains similar data, quite often even exactly the same data as before.