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
If the program is exiting, you do not have to worry about memory which was allocated with malloc or new. The OS will take care of it - anything in your process' virtual address space exclusively will go away when the process dies. If you're using shared memory or named pipes it could still be a concern.