Memory Optimization

aj-geddes/useful-ai-prompts/skills/memory-optimization

作者 aj-geddes3f5182cfd739無授權條款355 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫7 個月前更新

Profile and optimize application memory usage. Identify memory leaks, reduce memory footprint, and improve efficiency for better performance and reliability.

AI 產生的概覽

指導分析並最佳化應用程式記憶體用量,找出記憶體洩漏並降低記憶體佔用。

功能
此技能提供分析與最佳化應用程式記憶體用量的指引。內容涵蓋找出記憶體洩漏、降低記憶體佔用,以及提升效能與可靠性方面的效率。它指向記憶體分析、洩漏偵測、最佳化技術與監控目標等參考指南,並包含瀏覽器與 Node.js 分析的快速入門範例。
適用情境
當應用程式出現記憶體用量過高、疑似記憶體洩漏、效能緩慢、記憶體不足崩潰或擴充困難時使用。它用於診斷並降低執行中應用程式的記憶體消耗。
執行需求
不隨附指令碼,僅為說明與參考文件。分析範例涉及瀏覽器開發者工具與 Node.js 檢查,因此執行所述工作需要使用這些工具。

Memory Optimization

Table of Contents

Overview

Memory optimization improves application performance, stability, and reduces infrastructure costs. Efficient memory usage is critical for scalability.

When to Use

  • High memory usage
  • Memory leaks suspected
  • Slow performance
  • Out of memory crashes
  • Scaling challenges

Quick Start

Minimal working example:

javascript
// Browser memory profiling
// Check memory usageperformance.memory: {  jsHeapSizeLimit: 2190000000,    // Max available  totalJSHeapSize: 1300000000,    // Total allocated  usedJSHeapSize: 950000000       // Currently used}
// React DevTools Profiler- Open React DevTools → Profiler- Record interaction- See component renders and time- Identify unnecessary renders
// Chrome DevTools1. Open DevTools → Memory2. Take heap snapshot3. Compare before/after4. Look for retained objects5. Check retained sizes
// Node.js profilingnode --inspect app.js// Open chrome://inspect// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
Memory Profiling [blocked]Memory Profiling
Memory Leak Detection [blocked]Memory Leak Detection
Optimization Techniques [blocked]Optimization Techniques
Monitoring & Targets [blocked]Monitoring & Targets

Best Practices

✅ DO

  • Follow established patterns and conventions
  • Write clean, maintainable code
  • Add appropriate documentation
  • Test thoroughly before deploying

❌ DON'T

  • Skip testing or validation
  • Ignore error handling
  • Hard-code configuration values

來源與署名

來源:aj-geddes/useful-ai-prompts位於skills/memory-optimization提交3f5182c

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架