Memory leak using boost::regex_replace in Visual Studio
Hi...I need help bad. I just started using boost and it seemed very useful for doing regular expressions. I do have a problem and that is I have tons of memory leaks and I am not sure how or if it can be fixed. I have isolated the leak to the following section of code: for(iter = mapData.begin(); iter != mapData.end(); iter++) { // MH: Leak here const wchar_t * expressionText = (wchar_t *)(*iter).first.c_str(); const wchar_t * formatText = (wchar_t *)(*iter).second.c_str(); boost::wregex e1(expressionText); searchString = boost::regex_replace(searchString, e1, formatText); } Can someone please help me?
Mary Huther wrote:
Hi...I need help bad. I just started using boost and it seemed very useful for doing regular expressions. I do have a problem and that is I have tons of memory leaks and I am not sure how or if it can be fixed. I have isolated the leak to the following section of code:
for(iter = mapData.begin(); iter != mapData.end(); iter++) { // MH: Leak here const wchar_t * expressionText = (wchar_t *)(*iter).first.c_str(); const wchar_t * formatText = (wchar_t *)(*iter).second.c_str();
What does mapData contain, those C style casts look suspicious at best. Are you expecting regex to take over ownership of those pointers? As it most certainly does not do that. Apologies for asking the obvious questions. John.
participants (2)
-
John Maddock
-
Mary Huther