UMBC CMSC 201
Fall '06

CSEE | 201 | 201 F'06 | lectures | news | help

Memory Leaks

When your program ends, all of its memory is automatically freed and is available for the operating system to use for other programs.

If a program runs for a long time (e.g., Microsoft Word), it may need to allocate and then free memory as it runs.

C's free( ) function deallocates the memory that is pointed to by the pointer passed to it as an argument. free(ptr); deallocates the memory pointed to by ptr. This means that the operating system is free to assign it to another program.

A memory leak is a common kind of bug in which a program fails, for some reason, to free memory it no longer needs.

The result is often that the program grows and grows and grows without bound. As it grows, it slows down and may eventually crash the operating system.


CSEE | 201 | 201 F'06 | lectures | news | help

Last Modified - Tuesday, 22-Aug-2006 07:14:10 EDT