'Manual memory management limitations

Let’s say that a program is correct, when every piece of allocated memory is deallocated just as soon as it’s not needed.

Is it possible to make every possible program correct, without any memory management aid like RC, just plain free and malloc, no additional overhead?

My bet is that it is not possible, I saw a few projects like Lobster or V, which provide nearly static memory management through flow analysis, but in some cases RC is used automatically. Also some users report that memory deallocation is often delayed, but it may be just a solvable compiler issue.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source