Sunday, September 22, 2024

Re: Need some information about fork(2)

Dear Ingo,

While I agree with what you said, the decision of whether to free the
successful allocations in a program is not trivial. If nothing else,
opposed to the "fear" (as you put it) of not having the memory freed on
program exit is the other extreme: the inertia and complacency of not
doing it at all (or where needed), "since it gets released on program
exit anyway", and having leaks all over a long-running program. This
tends to happen (too) often, even (but most visibly) in well-known
complex programs. I agree that the "right thing" to do is somewhere in
the middle. Tools like ASan cannot help make the distinction, because
they cannot understand the program like humans do. My thoughts in my
previous email were based on psychology: people prefer to not have to
think too hard, so they don't free where needed, choosing the worse
outcome.

No comments:

Post a Comment