Memory leak: How risky not to free allocated memory.
I am revising old program, (not coded by me) which does not compile without -fwritable-string. These days, gcc does not accept this option. (ANSI string is const, so cannot modify. With that option, gcc-3 used to allocate writable memory for string, so that can be overwritten. It is a violation of ANSI rulebook.)
Program is a small pipe. I have no idea how much memory is allocated.
So far, I have done:
I managed to allocate necessary memory for these variables, copy into and and program itself look good.
So far, I have not done:
However, modifications happened all over the place, and I have not figured out overall program structure. At this moment, none of allocated memory is freed. I know it is not good, but not easy to keep track.
Web says that modern OS takes care of allocated memory requested by program when the program exits. Another Web says not freeing allocated memory is a good way to make memory leak.
If the former is correct, every time this program finishes, memory is freed, so my penguin stays healthy. If the latter, my penguin may get sick. Do I need to spend another three days to take care of allocated memory?
What is my best option?
I will appreciate suggestions.
|All times are GMT -5. The time now is 12:47 PM.|