c++ - std::string memory leak -


i've got class appcontroller , function connectplayer:

/* appcontroller.h */     class appcontroller     {           // other declarations ...       private:             static const string tag;     };  /* appcontroller.cpp */  #include "appcontroller.h" const string appcontroller::tag = "appcontroller";  appcontroller::appcontroller() {     /* code here...*/ }  void appcontroller::connectplayer() {     std::string port;     std::string host;     port = cm->getmenu()->getdata("port");     host = cm->getmenu()->getdata("host");     this->setstate("connecting...");     logger::info(tag, "port: " + port);     logger::info(tag, "host: " + host); } 

and when execute program, valgrind:

==7848== 25 bytes in 1 blocks lost in loss record 160 of 671 ==7848==    @ 0x402842f: operator new(unsigned int) (vg_replace_malloc.c:255) ==7848==    0x4210a83: std::string::_rep::_s_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16) ==7848==    0x4212cf7: char* std::string::_s_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16) ==7848==    0x4212e65: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16) ==7848==    0x8080501: appcontroller::connectplayer() (in /home/maine/escritorio/taller7542/ultimaversion/src/main) 

any ideas? thank in advance!

you have std::string objects in global scope: appcontroller::tag.

when application finished in not normal way you've got these kind of valgrind errors global objects. nothing worry.

if (cannot/don't want to) change program - read doc: http://valgrind.org/docs/manual/manual-core.html#manual-core.suppress rid of error.


Comments