Memory Leak Terminology – Why Is It Called a Memory Leak?

cheapmemory usageterminology

I am a hobbyist programmer, bit of a stickler for terminology, currently learning C and recently came across the concept of Memory Leak. Now, I do understand what it means. Dynamic memory allocated to a program is not returned by the program.

But where does the term 'leak' come from? Is it coming from the fact that other programs cannot access the dynamic memory, since one is already hogging it, and thus total memory available from the OS to the heap is reduced and therefore "leaked" to the one hogging it? Basically, are we see the memory leak from the OS's perspective? And therefore saying that it is leaked to the program?

Best Answer

Look at it at the other way, from the system perspective. You have a giant pool of free memory (free ram memory) where different programs can make use of. But all of their used resources should be returned sooner or later, or at least being used the entire time. When you no longer need it you should return it to the pool of free memory. Applications that keep asking for memory from the pool but never return it when they're done using it, cause a leak in the free memory pool until they've stopped. The program is a leak to the pool of free memory and I think from that perspective the term memory leak is a correct naming.

So we'll see the leak from the system's perspective.