Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are memory leaks common?

Tags:

memory-leaks

Is it due to basic misunderstandings of how memory is dynamically allocated and deallocated on the programmer's part? Is it due to complacency?

like image 930
Brandon Tiqui Avatar asked Jan 27 '10 03:01

Brandon Tiqui


1 Answers

No. It's due to the sheer amount of accounting it takes to keep track of every memory allocation. Who is responsible for allocating the memory? Who is responsible for freeing it? Ensuring that you use the same API to allocate and free the memory, etc... Ensuring you catch every possible program flow and clean up in every situation(for example, ensure you clean up after you catch an error or exception). The list goes on...

like image 58
Jesse Weigert Avatar answered Oct 21 '22 09:10

Jesse Weigert