I believe that as soon as the process that allocated the memory finishes, all the memory that it allocated is returned to the system - unless it spawns new processes that are still running....
However the danger with memory leaks is that your process may continually consume more and more memory - this is especially relevant for process that need to be running constantly.
In addition, if you do not free memory, then your program may have intermittent errors that are very hard to track down.
For example you go over the bounds of an array by accident. Sometimes when you run the program, the neighbouring memory belongs to your program - it was malloc'ed but not freed yet. In this case it will not generate an error. You may run it another time, and the neighbouring memory does not belong to you, and you will generate a segmentation fault.
By the way, if you use C++, you do not need to use malloc, use new instead.