We make mistakes. We will always make mistakes. Heaps of modern software ships with memory leaks these days. Vista still bluescreens.
There's two ways this problem is solved:
- Application-level memory protection
- Don't give the programmer pointers (Java, .NET, python, etc)
The problem with memory protection is that its really expensive. Context switches take ages because the TLB has to be flushed. On modern operating systems its about ~5 million clock cycles per context switch. I don't know how much of that is due to memory protection, but I think its quite a lot.
Pointerless languages solve the problem in another way. They just don't give the programmer pointers. Simple.
Languages without pointers are often shouted down by the C and C++ zealots because they're slow. (Oh have a cry). Remember though, when you use a pointerless language on a modern computer you're still paying the context switching overhead because memory protection is still used.
How do we fix it?
I don't think telling everyone to become better programmers actually works. Its really hard to write large systems with no memory bugs. Microsoft sure hasn't done it with vista.
Actually, I think the answer is to stop using pointers entirely. If we do that, memory protection is no longer necessary. Without memory protection, everything goes faster (especially threaded programs). Once compilers are more mature, JIT stuff like .NET should perform better than C and it will have no memory bugs.
Best of both worlds for the win.