I just wrote a code in C++ which does some string manipulation, but when I ran valgrind over, it shows some possible memory leaks. Debugging the code to granular level I wrote a
To add a different opinion.
Such code is not harmful hat all. The OS will care for everything when the process terminates. Everything else results in an unstable OS. Just ensure that your persistent data (files, ...) is consistent.
To go a bit further and provocatively states, explicitly freeing memory on program exit can be harmful.
main
(*) and kill your program insteadDo you risk this just to make Valgrind give you a specific output?(**)
(*)
#include
using namespace std;
std::string myname("Is there any leaks");
int main() {
exit(0);
}
(**) Well, of course the output of any memory analyzer is more useful without "noise". What about only freeing memory explicitly on exit in debug mode?