Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:21:07 +08:00
commit 58e7c2f58b
8 changed files with 186 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
{
"name": "memory-leak-detector",
"description": "Detect memory leaks and analyze memory usage patterns",
"version": "1.0.0",
"author": {
"name": "Claude Code Plugins",
"email": "[email protected]"
},
"skills": [
"./skills"
],
"commands": [
"./commands"
]
}

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# memory-leak-detector
Detect memory leaks and analyze memory usage patterns

34
commands/detect-leaks.md Normal file
View File

@@ -0,0 +1,34 @@
---
description: Detect potential memory leaks in code
---
# Memory Leak Detector
Analyze code for potential memory leaks and improper resource management.
## Detection Patterns
1. **Event Listeners**: Unremoved event listeners
2. **Closures**: Variables captured in closures preventing GC
3. **Timers**: Uncancelled setTimeout/setInterval
4. **Cache Growth**: Unbounded cache or collection growth
5. **Circular References**: Objects referencing each other
6. **DOM References**: Detached DOM nodes held in memory
7. **Global Variables**: Unnecessary global state accumulation
## Analysis Process
1. Search for common leak patterns in codebase
2. Identify resource allocation without cleanup
3. Check for proper disposal in cleanup methods
4. Analyze object lifecycle management
5. Generate detailed report with locations and fixes
## Output
Provide markdown report with:
- Identified leak patterns with severity ratings
- File locations and line numbers
- Code snippets showing the issue
- Recommended fixes with examples
- Prevention strategies

61
plugin.lock.json Normal file
View File

@@ -0,0 +1,61 @@
{
"$schema": "internal://schemas/plugin.lock.v1.json",
"pluginId": "gh:jeremylongshore/claude-code-plugins-plus:plugins/performance/memory-leak-detector",
"normalized": {
"repo": null,
"ref": "refs/tags/v20251128.0",
"commit": "d00e5498e92f68d9e410b9d27441fa2d71c008bc",
"treeHash": "d8281f402a471aff7a3dd73f755ee21650e0360825e9de47b548e36700e33f70",
"generatedAt": "2025-11-28T10:18:33.859097Z",
"toolVersion": "publish_plugins.py@0.2.0"
},
"origin": {
"remote": "git@github.com:zhongweili/42plugin-data.git",
"branch": "master",
"commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390",
"repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data"
},
"manifest": {
"name": "memory-leak-detector",
"description": "Detect memory leaks and analyze memory usage patterns",
"version": "1.0.0"
},
"content": {
"files": [
{
"path": "README.md",
"sha256": "9ea246c9e7fb116a44b97fd83bfb0e2e286c4ed93f549a60ebef50d1ec3e5796"
},
{
"path": ".claude-plugin/plugin.json",
"sha256": "29bcf7536f268bb6f37f98a46794a7d094f0aa59e2710a86bc57700bddf2e6b5"
},
{
"path": "commands/detect-leaks.md",
"sha256": "a6faf441b683b81ae470ff092db2ae63366266c7d40d8965613aef763d8d18cb"
},
{
"path": "skills/memory-leak-detector/SKILL.md",
"sha256": "19bba98b96199ca8682a33df0a0b281058cf063d38362142c0eea8d0829d56e3"
},
{
"path": "skills/memory-leak-detector/references/README.md",
"sha256": "32c25111af368453a70125adf03e2d9f361a821af15aee2c3c2aab854e92d56c"
},
{
"path": "skills/memory-leak-detector/scripts/README.md",
"sha256": "56d9ea70146f338f8f8a737265b3293ab00dab634c1144e1398bdde68cc72222"
},
{
"path": "skills/memory-leak-detector/assets/README.md",
"sha256": "f566a2694628726a7259ef99895488514e6c63e87b6fe20a2d6052a88c3ae51c"
}
],
"dirSha256": "d8281f402a471aff7a3dd73f755ee21650e0360825e9de47b548e36700e33f70"
},
"security": {
"scannedAt": null,
"scannerVersion": null,
"flags": []
}
}

View File

@@ -0,0 +1,52 @@
---
name: detecting-memory-leaks
description: |
This skill enables Claude to detect potential memory leaks and analyze memory usage patterns in code. It is triggered when the user requests "detect memory leaks", "analyze memory usage", or similar phrases related to memory leak detection and performance analysis. The skill identifies potential issues such as unremoved event listeners, closures preventing garbage collection, uncancelled timers, unbounded cache growth, circular references, detached DOM nodes, and unnecessary global state accumulation. It then provides detailed fix recommendations. Use this skill to proactively identify and resolve memory leaks, improving application performance and stability.
allowed-tools: Read, Write, Edit, Grep, Glob, Bash
version: 1.0.0
---
## Overview
This skill helps you identify and resolve memory leaks in your code. By analyzing your code for common memory leak patterns, it can help you improve the performance and stability of your application.
## How It Works
1. **Initiate Analysis**: The user requests memory leak detection.
2. **Code Analysis**: The plugin analyzes the codebase for potential memory leak patterns.
3. **Report Generation**: The plugin generates a report detailing potential memory leaks and recommended fixes.
## When to Use This Skill
This skill activates when you need to:
- Detect potential memory leaks in your application.
- Analyze memory usage patterns to identify performance bottlenecks.
- Troubleshoot performance issues related to memory leaks.
## Examples
### Example 1: Identifying Event Listener Leaks
User request: "detect memory leaks in my event handling code"
The skill will:
1. Analyze the code for unremoved event listeners.
2. Generate a report highlighting potential event listener leaks and suggesting how to properly remove them.
### Example 2: Analyzing Cache Growth
User request: "analyze memory usage to find excessive cache growth"
The skill will:
1. Analyze cache implementations for unbounded growth.
2. Identify caches that are not properly managed and recommend strategies for limiting their size.
## Best Practices
- **Code Review**: Always review the reported potential leaks to ensure they are genuine issues.
- **Regular Analysis**: Incorporate memory leak detection into your regular development workflow.
- **Targeted Analysis**: Focus your analysis on specific areas of your code that are known to be memory-intensive.
## Integration
This skill can be used in conjunction with other performance analysis tools to provide a comprehensive view of application performance.

View File

@@ -0,0 +1,7 @@
# Assets
Bundled resources for memory-leak-detector skill
- [ ] report_template.md: Template for generating memory leak analysis reports.
- [ ] example_code_with_leaks/: Directory containing example code snippets with memory leaks.
- [ ] example_code_fixed/: Directory containing example code snippets with memory leaks fixed.

View File

@@ -0,0 +1,7 @@
# References
Bundled resources for memory-leak-detector skill
- [ ] memory_leak_patterns.md: Documentation of common memory leak patterns and how to identify them.
- [ ] memory_analysis_tools.md: Documentation on available memory analysis tools and their usage.
- [ ] code_example_fixes.md: Example fixes for common memory leak scenarios.

View File

@@ -0,0 +1,7 @@
# Scripts
Bundled resources for memory-leak-detector skill
- [ ] analyze_memory.py: Script to execute memory analysis tools and parse results.
- [ ] generate_report.py: Script to generate a human-readable report from the analysis results.
- [ ] setup_environment.sh: Script to set up the necessary environment for memory leak detection (e.g., installing tools).