# Memory Leak

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

- Skill: `zakirkun/memory-leak` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add zakirkun/memory-leak`
- Raw SKILL.md: https://api.skillmd.com/api/skills/zakirkun/memory-leak/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: zakirkun (https://skillmd.com/u/zakirkun)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/zakirkun/memory-leak

---


# 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

