Memory Leak

Detects common memory leak patterns including unreleased heap allocations, unclosed file handles, and missing deallocation in error paths.

zakirkun Updated

File contents

Memory Leak

Overview

Memory leaks cause gradual memory consumption growth until the process exhausts available memory (OOM). In long-running servers, even small leaks cause eventual crashes or degraded performance.

Common patterns:

  • malloc() without corresponding free()
  • new without delete in C++
  • Missing free() in error exit paths
  • Goroutine leaks in Go

Remediation

  • Use RAII (C++) or smart pointers to manage memory automatically
  • Use ASan/Valgrind to detect leaks
  • Go: Use context cancellation to stop goroutines
  • Ensure all code paths free() allocated resources

zakirkun/ice-tea/tree/main/skills/memory/memory-leak commit 710dd4b5a6

Frequently asked questions

npx skillmds@latest add zakirkun/memory-leak