Click here to Skip to main content
15,911,891 members

Comments by creanberries__87 (Top 3 by date)

creanberries__87 26-Oct-15 6:26am View    
I've tried your way, but it didn't resolve the memory leak.
creanberries__87 25-Oct-15 17:59pm View    
Hi,
Firstly, thanks for your time and reply. I've just found the cause of leak. The problem is about that the map is static. The class I mentioned, MyClass is a static class, all members of it are static. And this event, translateInfo is called in lots of places, in another non-static class( MyNonStaticClass ). I am not sure but,I suppose, when I called translateString, it adds std::string type variables, and also references to the class(MyNonStaticClass) which uses MyClass::translateString.
When the object of MyNonStaticClass is destroyed, the reference which is hold by static map, is not released. Could you please share your comments about the exact cause of it ?
creanberries__87 24-Oct-15 10:53am View    
I'2 tried the way you suggested as the following but it didn't worked ;

while( strcmp( s.c_str(), myMap[i] ) != 0 )
// while( s != myMap[i])


By the way, I've examined the output of unit test run. It gives the following error in some places ;

Block size: 28, Address: 0x688d514, Back Trace:
2. Tests(__gnu_cxx::new_allocator<std::_rb_tree_node<std::pair<std::string const,="" std::string=""> > >::allocate(unsigned int, void const*)) [0x806db1e]
3. Tests(std::_Rb_tree<std::string, std::pair<std::string="" const,="" std::string="">, std::_Select1st<std::pair<std::string const,="" std::string=""> >, std::less<std::string>, std::allocator<std::pair<std::string const,="" std::string=""> > >::_M_get_node()) [0x806da43]
4. Tests(std::_Rb_tree<std::string, std::pair<std::string="" const,="" std::string="">, std::_Select1st<std::pair<std::string const,="" std::string=""> >, std::less<std::string>, std::allocator<std::pair<std::string const,="" std::string=""> > >::_M_create_node(std::pair<std::string const,="" std::string=""> const&)) [0x806d96a]
5. Tests(std::_Rb_tree<std::string, std::pair<std::string="" const,="" std::string="">, std::_Select1st<std::pair<std::string const,="" std::string=""> >, std::less<std::string>, std::allocator<std::pair<std::string const,="" std::string=""> > >::_M_insert_(std::_Rb_tree_node_base const*, std::_Rb_tree_node_base const*, std::pair<std::string const,="" std::string=""> const&)) [0x806d67a]
6. Tests(std::_Rb_tree<std::string, std::pair<std::string="" const,="" std::string="">, std::_Select1st<std::pair<std::string const,="" std::string=""> >, std::less<std::string>, std::allocator<std::pair<std::string const,="" std::string=""> > >::_M_insert_unique_(std::_Rb_tree_const_iterator<std::pair<std::string const,="" std::string=""> >, std::pair<std::string const,="" std::string=""> const&)) [0x806d2bc]
7. Tests(std::map<std::string, std::string,="" std::less<std::string="">, std::allocator<std::pair<std::string const,="" std::string=""> > >::insert(std::_Rb_tree_iterator<std::pair<std::string const,="" std::string=""> >, std::pair<std::string const,="" std::string=""> const&)) [0x806cfb2]
8. Tests(std::map<std::string, std::string,="" std::less<std::string="">, std::allocator<std::pair<std::string const,="" std::string=""> > >::operator[](std::string const&)) [0x806ca94]
9. MyClass::translateInput(std::string const&)) [0x430267c]

Do you have any comment about this ?

Thanks in advance,
Cranberries