Memory Leaks

Learn what a memory leak is, its symptoms, and its causes.

An unhandled error condition leads to a crash immediately. A program will hang as soon as it starts waiting for a condition (that goes unfulfilled eventually). Unlike these two, the effect of a resource leak on a program can remain undetected for quite some time. The ultimate result of a resource leak on a product and the environment where it runs could vary based on the platform. A variety of platform-specific tools are needed to go after them. In this lesson, we’ll learn about memory and resource leaks in general. We’ll start with memory leaks, which are by far the most commonly seen among all resource leaks.

What is a memory leak?

Even the most straightforward software program has to handle memory in the form of variables which are instantiated data types or data structures. The data types a programming language offers are typically basic, like integer, character, float, etc., and the compounded ones are composed of multiple instances of these basic types, like arrays, lists, etc. The compounded data types can be of any length the runtime environment allows. The length is usually known at compile-time for data types like arrays, but for lists, etc., the size is completely unbounded.

Apart from data structures and data types, platforms provide their programs with a ...