本文へスキップ
Skillpedia
WebサイトとUI(フロントエンド)75k · #2933

memory-leaks

できること

このスキルは、不要になってもメモリを使い続けるパターンをブラウザ側のコードで確認します。長時間使うと遅くなるシングルページアプリを作るフロントエンド開発者向けです。

使う場面

  • ✓Webアプリにメモリリークがないか確認してほしいとき。
  • ✓利用者がページを開いている時間や、画面を移動する回数が増えるほど遅くなるとき。
  • ✓コンポーネントをレビューし、リスナー、タイマー、リクエストが後片付けされているか確かめたいとき。

スキルのリンク

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/memory-leaks/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/memory-leaks/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

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.

repo: thedaviddias/Front-End-Checklist

人気

GitHubのスター
75k
ランキング
#2933
ライセンス
MIT
更新日
2026/10/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル