What’s a memory leak?

A memory leak is a condition in which an incremental but steady loss of computer memory takes place, usually as the result of a program failing to release unused memory back into the pool of available memory.  Even a relatively small memory leak can eventually cripple a system, given enough time. See wikipedia for a great discussion of memory leaks.

This site is here to help you understand some of the  issues and causes that can lead to memory leaks and some strategies and techniques you can use to detect, identify and eliminate them.

The issues and causes include

Charting Memory Usage with MemoryScape

Charting Memory Usage with MemoryScape

  • Re-use of code
  • Code that is primarily unit tested with short runs on small datasets
  • Unexpected / unorthodox use of software or library routines
  • Leaks that are not immediately fatal can often linger in a code base
  • Mismatch in memory usage patterns across APIs
  • Unexpected loops (code re-use)
  • Pointer errors
  • Failure in reference counting
  • Logic error in destructors
  • Failure to “clean up”

Strategies and techniques include

  • Using Valgrind to look for memory problems
  • Using MemoryScape to look at memory usage across a cluster
  • Using memscript for leak checking
  • Using tvscript to automate leak checking within loops
  • Run to the end

[Next: Key issues and causes]