Дана 24/09/22 09:08PM, Otto Moerbeek написа: > All correct, but still, on process exit all resources used by a > program are cleaned up. In that sense it is not a memory leak to not > call free. Especially for one-time allocations.
Still, while most OSes (including OpenBSD) do free the leaked memory on program termination, there are some which don't.[1] I think it is better to make a habit of free(3)ing every successfully allocated chunk of memory and err on the side of redundancy. > It is differrent if the malloc is e.g. in a loop, causing memory usage > to grow while executing the program. That is a memory leak you want to > fix, especially if the program is a long running one, like a daemon. Or a web browser. Leaks are more noticeable in complex software left running for a long time. [1]: https://stackoverflow.com/a/2975844/184064