memory-leak-detection by aj-geddes/useful-ai-prompts
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill memory-leak-detection识别并修复内存泄漏,以防止内存不足崩溃并优化应用程序性能。
最小工作示例:
import v8 from "v8";
import fs from "fs";
class MemoryProfiler {
takeSnapshot(filename: string): void {
const snapshot = v8.writeHeapSnapshot(filename);
console.log(`Heap snapshot saved to ${snapshot}`);
}
getMemoryUsage(): NodeJS.MemoryUsage {
return process.memoryUsage();
}
formatMemory(bytes: number): string {
return `${(bytes / 1024 / 1024).toFixed(2)} MB`;
}
printMemoryUsage(): void {
const usage = this.getMemoryUsage();
console.log("Memory Usage:");
console.log(` RSS: ${this.formatMemory(usage.rss)}`);
console.log(` Heap Total: ${this.formatMemory(usage.heapTotal)}`);
console.log(` Heap Used: ${this.formatMemory(usage.heapUsed)}`);
console.log(` External: ${this.formatMemory(usage.external)}`);
// ... (完整实现请参阅参考指南)
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
references/ 目录下的详细实现:
| 指南 | 内容 |
|---|---|
| Node.js 堆快照 | Node.js 堆快照 |
| 内存泄漏检测中间件 | 内存泄漏检测中间件 |
| 常见内存泄漏模式 | 常见内存泄漏模式 |
| Python 内存分析 | Python 内存分析 |
| 用于缓存的 WeakMap/WeakRef | 用于缓存的 WeakMap/WeakRef |
| 生产环境内存监控 | 生产环境内存监控 |
每周安装量
130
代码仓库
GitHub 星标数
121
首次出现
2026年1月21日
安全审计
安装于
opencode109
gemini-cli103
codex103
claude-code94
cursor93
github-copilot87
Identify and fix memory leaks to prevent out-of-memory crashes and optimize application performance.
Minimal working example:
import v8 from "v8";
import fs from "fs";
class MemoryProfiler {
takeSnapshot(filename: string): void {
const snapshot = v8.writeHeapSnapshot(filename);
console.log(`Heap snapshot saved to ${snapshot}`);
}
getMemoryUsage(): NodeJS.MemoryUsage {
return process.memoryUsage();
}
formatMemory(bytes: number): string {
return `${(bytes / 1024 / 1024).toFixed(2)} MB`;
}
printMemoryUsage(): void {
const usage = this.getMemoryUsage();
console.log("Memory Usage:");
console.log(` RSS: ${this.formatMemory(usage.rss)}`);
console.log(` Heap Total: ${this.formatMemory(usage.heapTotal)}`);
console.log(` Heap Used: ${this.formatMemory(usage.heapUsed)}`);
console.log(` External: ${this.formatMemory(usage.external)}`);
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Node.js Heap Snapshots | Node.js Heap Snapshots |
| Memory Leak Detection Middleware | Memory Leak Detection Middleware |
| Common Memory Leak Patterns | Common Memory Leak Patterns |
| Python Memory Profiling | Python Memory Profiling |
| WeakMap/WeakRef for Cache | WeakMap/WeakRef for Cache |
| Memory Monitoring in Production | Memory Monitoring in Production |
Weekly Installs
130
Repository
GitHub Stars
121
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode109
gemini-cli103
codex103
claude-code94
cursor93
github-copilot87
TanStack Query v5 完全指南:React 数据管理、乐观更新、离线支持
2,500 周安装