memory-leaks
できること
このスキルは、不要になってもメモリを使い続けるパターンをブラウザ側のコードで確認します。長時間使うと遅くなるシングルページアプリを作るフロントエンド開発者向けです。
使う場面
- ✓Webアプリにメモリリークがないか確認してほしいとき。
- ✓利用者がページを開いている時間や、画面を移動する回数が増えるほど遅くなるとき。
- ✓コンポーネントをレビューし、リスナー、タイマー、リクエストが後片付けされているか確かめたいとき。
スキルのリンク
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/memory-leaks/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のWebアプリは使い続けるほど遅くなります。コードにメモリリークがないか確認してもらえますか。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、削除されないイベントリスナー、動き続けるタイマー、削除された要素への参照、画面が消えた後も続くリクエストを探します。そのうえで、後片付けの手順を提案します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Prevent common memory leak patterns
Memory leaks cause applications to consume increasing amounts of memory over time, eventually slowing the browser tab or crashing it. In single-page applications, where users don't reload the page, small leaks in components accumulate with each navigation and can make an app unusable after 30 minutes of use.
Quick Reference
- Remove event listeners when the element or component is destroyed
- Clear setInterval and setTimeout when they're no longer needed
- Avoid storing DOM references in long-lived objects after elements are removed
- Use WeakMap and WeakSet when storing metadata about objects you don't own
- Use AbortController to cancel stale async requests when UI state changes
Check
Analyze this code for memory leak patterns: uncleaned event listeners, retained DOM references after removal, closures holding large objects, and uncleared timers. Also flag fetches and async tasks that continue after the owning component or view is gone.
Fix
Fix the memory leaks in this code by cleaning up event listeners, clearing timers, canceling stale async requests, and releasing DOM references when they're no longer needed.
Explain
Explain the four most common JavaScript memory leak patterns and how to detect them with Chrome DevTools.
Code Review
Review scripts, client components, and browser execution paths related to Prevent common memory leak patterns. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/javascript/memory-leaks
よくある質問
リークがあるかどうか、自分で確かめるにはどうすればよいですか?
このスキルは、Chrome DevTools でメモリ使用量を監視し、リークのパターンを見つけることを勧めています。
AbortController は何のために使われますか?
利用者が移動した後の古いリクエストを取り消し、古い画面を結果で更新しないようにするために使います。
最もよくあるリークのパターンは何ですか?
後片付けされないイベントリスナー、DOM への参照の保持、大きなオブジェクトを保持するクロージャー、解除されないタイマーなどです。
詳細
作者による元の説明
Use when reviewing scripts, client components, bundles, or runtime behavior related to Prevent common memory leak patterns. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.
人気
- GitHubのスター
- 75k
- ランキング
- #2933
- ライセンス
- MIT
- 更新日
- 2026/10/31
コメント
- …
このリポジトリの他のスキル
frontendchecklist
75kコマンドラインツールを使って、フロントエンドのコードとライブページを、アクセシビリティ、速度、SEO、セキュリティに関する380以上のルールと照らし合わせて確認します。
frontend-checklist-global
75kフロントエンドのプロジェクトを、386のFront-End Checklistのルールすべてと照らし合わせて監査し、見つかった問題ごとに具体的な修正方法を示します。
404-page
75k見つからないページの画面に役立つリンクがあり、本物の404ステータスを返すかを確認し、迷った訪問者が目的のページを見つけられるようにします。
about-page
75kサイトの運営者が誰かを説明する、分かりやすいAboutページがあるかを確認し、訪問者と検索エンジンからの信頼を高めます。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。