4 ms·
To quota GNU libc manual: > There is no point in freeing blocks at the end of a program, because all of the program’s space is given back to the system when th
by j16sdiz 4y ago
To quota GNU libc manual:
> There is no point in freeing blocks at the end of a program, because all of the program’s space is given back to the system when the process terminates.
https://www.gnu.org/software/libc/manual/html_node/Freeing-after-Malloc.html https://www.gnu.org/software/libc/manual/html_node/Freeing-a...
I think many GNU tools just never free any memory.
For example, GCC :
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66339 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66339
--
edit: added GCC as example.
- baggy_trough 4y agoOne point would be to be able to detect memory leaks with tools.
- matvore 4y agoThe last time I used a leak finder, a memory allocation which still has a ptr to it is not a leak. You are conflating unfreed memory with unreferencable memory.
- TazeTSchnitzel 4y agoReachability is one strategy for detecting leaks but it's not the only one. Checking for unfreed memory is easier to implement.
- anthk 4y agoOn GCC, the memory usage on compiling C++ vs Clang can be night and day. You can compile large C++ projects in a GB of RAM based netbook with Clang and ZRAM.
- colonwqbang 4y ago> There is no point in freeing blocks at the end of a program ...unless you are trying to find memory leaks in your program. In that case it would be very helpful if the program, and the libraries it uses, were written to actively free all allocated memory. > I think many GNU tools just never free any memory It is absolutely true that some GNU software (including libraries like glib) allocate memory that they never intend to free. This causes leak analysis of programs that link with these libraries to be more painful than necessary.
- miohtama 4y agoTo work around leaks, just don’t run your GNU programs for very long (:
- Maken 4y agoMaybe this is the intended use case of timeout(1).
- DominoTree 4y agoMany GNU programs will helpfully terminate periodically with SIGSEGV to help prevent memory leaks from becoming a problem
- systems_glitch 4y ago"I run gmake and gcc, And I ain't never called malloc without calling free."
- bjackman 4y agoWell yeah if your program does something and then terminates then memory leaks are not an issue. If your process is a server or a daemon or something then restarting each instance every N hours is a nice backstop but memory leaks are still a frightening spanner in the works!