memory-leak-fixer

Detect and fix native ownership and disposal memory leaks in SkiaSharp C# bindings with red-green regression tests.

5.6k|645|Updated Feb 22, 2016
One-click install
npx skills add https://github.com/mono/SkiaSharp --skill memory-leak-fixer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: memory-leak-fixer
Source: https://github.com/mono/SkiaSharp/tree/main/.agents/skills/memory-leak-fixer
Command: npx skills add https://github.com/mono/SkiaSharp --skill memory-leak-fixer

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

SkiaSharp is a thin managed wrapper over native Skia, so its recurring high-impact bugs are native ownership and disposal leaks: undisposed SKObject handles, wrong owns: flags, double-dispose of same-instance returns, unremoved event subscriptions, and fixed-pointer lifetime bugs. Manually hunting these across the bindings is slow and error-prone, and fixes without empirical proof often swap a leak for a crash.

Core Features & Use Cases

  • Leak scanning across 11 catalogued focus areas: Rotates through real historical SkiaSharp leak patterns (undisposed handles, wrong owns: flags, clone double-frees, delegate-proxy lifetimes, and more) with grep starting points and per-area anti-patterns.
  • Empirical confirmation before fixing: Proves each candidate with a WeakReference plus forced-GC probe against the shipped SkiaSharp NuGet package before any code change.
  • Red-green regression workflow: Writes a failing test first, applies the minimal idiomatic fix inside binding/** or source/**, verifies both directions, then files a labeled issue and a linked draft PR.
  • Use Case: A maintainer asks the agent to scan SkiaSharp for disposal leaks; the skill picks a focus area, confirms a real leak empirically, fixes it with a passing regression test, and opens a draft PR that auto-closes the filed issue.

Quick Start

Ask the agent to scan SkiaSharp for memory leaks and fix the strongest confirmed candidate with a regression test and draft PR.

Frequently Asked Questions about memory-leak-fixer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find memory leaks in SkiaSharp?

Run the memory-leak-fixer skill, which scans the C# bindings and view layers against 11 catalogued leak patterns drawn from real historical SkiaSharp fixes. It confirms each candidate empirically with a WeakReference and forced-GC probe before proposing any fix.

How does the skill prove a leak is real before fixing it?

It builds a throwaway test project referencing the shipped SkiaSharp NuGet package and runs control, leaky, and mitigation allocations tracked by WeakReference. The leak is confirmed only if leaky subjects stay alive after forced GC while control subjects are collected.

Can this skill fix leaks in native Skia C++ code?

No. The skill is scoped to managed C# only, covering binding/** and source/**. Leaks whose only fix lives under externals/skia/** are filed as an issue with a proposed native fix, but no pull request is opened.

What kinds of leaks does the SkiaSharp leak scan cover?

It covers 11 focus areas including undisposed native handles, wrong owns: flags, same-instance double-dispose, view event retention, fixed-pointer lifetime, finalizer ordering, clone double-frees, singleton disposal, un-nulled fields, delegate-proxy lifetimes, and allocation-failure paths.

What happens when the scan finds no leak?

A quiet run is treated as a successful outcome because the codebase is mature and hardened. The skill reports the scanned focus area and emits a single noop safe output rather than inventing a finding.