axiom-memory-debugging▌
charleswiltgen/axiom · updated Apr 8, 2026
MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.
Memory issues manifest as crashes after prolonged use. Core principle 90% of memory leaks follow 3 patterns (retain cycles, timer/observer leaks, collection growth). Diagnose systematically with Instruments, never guess.
Memory Debugging
Overview
Memory issues manifest as crashes after prolonged use. Core principle 90% of memory leaks follow 3 patterns (retain cycles, timer/observer leaks, collection growth). Diagnose systematically with Instruments, never guess.
Example Prompts
- "My app crashes after 10-15 minutes with no error messages"
- "Memory jumps from 50MB to 200MB+ on a specific action — leak or cache?"
- "View controllers don't deallocate after dismiss"
- "Timers/observers causing memory leaks — how to verify?"
- "App uses 200MB and I don't know if that's normal"
Red Flags — Memory Leak Likely
- Progressive memory growth: 50MB → 100MB → 200MB (not plateauing)
- App crashes after 10-15 minutes with no error in Xcode console
- Memory warnings appear repeatedly in device logs
- View controllers don't deallocate after dismiss (visible in Memory Graph Debugger)
- Same operation run multiple times causes linear memory growth
Leak vs normal: Normal = stays at 100MB. Leak = 50MB → 100MB → 150MB → 200MB → CRASH.
Mandatory First Steps
ALWAYS diagnose FIRST (before reading code):
- Check device logs for "Memory pressure critical", "Jetsam killed", "Low Memory"
- Use Memory Graph Debugger (below) — shows object count growth
- Xcode → Product → Profile → Memory. Perform action 5 times, note if memory keeps growing
What this tells you: Flat = not a leak. Linear growth = classic leak. Spike then flat = normal cache. Spikes stacking = compound leak.
Why diagnostics first: Finding leak with Instruments: 5-15 min. Guessing: 45+ min.
Detecting Leaks — Step by Step
Step 1: Memory Graph Debugger (Fastest)
- Open app in simulator
- Debug → Memory Graph Debugger (or toolbar icon)
- Look for PURPLE/RED circles with "⚠" badge
- Click them → Xcode shows retain cycle chain
Step 2: Instruments (Detailed Analysis)
- Product → Profile (Cmd+I) → "Memory" template
- Perform action 5-10 times
- Memory line goes UP for each action? = Leak confirmed
Key instruments: Heap Allocations (object count), Leaked Objects (direct detection), VM Tracker (by type).
Step 3: Deallocation Check
// Add deinit logging to suspect classes
class MyViewController: UIViewController {
deinit { print("✅ MyViewController deallocated") }
}
@MainActor
class ViewModel: ObservableObject {
deinit { print("✅ ViewModel deallocated") }
}
Navigate to view, navigate away. See "✅ deallocated"? Yes = no leak. No = retained somewhere.
Jetsam (Memory Pressure Termination)
Jetsam is not a bug — iOS terminates background apps to free memory. Not a crash (no crash log), but frequent kills hurt UX.
| Termination | Cause | Solution |
|---|---|---|
| Memory Limit Exceeded | Your app used too much memory | Reduce peak footprint |
| Jetsam | System needed memory for other apps | Reduce background memory to <50MB |
Reducing Jetsam Rate
Clear caches on backgrounding:
// SwiftUI
.onChange(of: scenePhase) { _, newPhase in
if newPhase == .background {
imageCache.clearAll()
URLCache.shared.removeAllCachedResponses()
}
}
State Restoration
Users shouldn't notice jetsam. Use @SceneStorage (SwiftUI) or stateRestorationActivity (UIKit) to restore navigation position, drafts, and scroll position.
Monitoring with MetricKit
class JetsamMonitor: NSObject, MXMetricManagerSubscriber {
func didReceive(_ payloads: [MXMetricPayload]) {
for payload in payloads {
guard let exitData = payload.applicationExitMetrics else { continue }
let bgData = exitData.backgroundExitData
if bgData.cumulativeMemoryPressureExitCount > 0 {
// Send to analytics
}
}
}
}
App memory grows while in USE? → Memory leak (fix retention)
App killed in BACKGROUND? → Jetsam (reduce bg memory)
Common Memory Leak Patterns (With Fixes)
Pattern 1: Timer Leaks (Most Common — 50% of leaks)
Why [weak self] alone doesn't fix timer leaks: The RunLoop retains scheduled timers. [weak self] only prevents the closure from retaining self — the Timer object itself continues to exist and fire. You must explicitly invalidate() to break the RunLoop's retention.
❌ Leak — Timer never invalidated
progressTimer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { [weak self] _ in
self?.updateProgress()
}
// Timer never stopped → RunLoop keeps it alive and firing forever
✅ Best fix: Combine (auto-cleanup)
cancellable = Timer.publish(every: 1.0, tolerance: 0.1, on: .main, in: .default)
.autoconnect()
.sink { [weak self] _ in self?.updateProgress() }
// No deinit needed — cancellable auto-cleans when released
Alternative: Call timer?.invalidate(); timer = nil in both the appropriate teardown method (viewWillDisappear, stop method, etc.) AND deinit.
For timer crash patterns (EXC_BAD_INSTRUCTION) and RunLoop mode issues, see
axiom-timer-patterns.
Pattern 2: Observer/Notification Leaks (25% of leaks)
❌ Leak — No removeObserver
NotificationCenter.default.addObserver(self, selector: #selector(handle),
name: AVAudioSession.routeChangeNotification, object: nil)
// No matching removeObserver → accumulates listeners
✅ Best fix: Combine publisher
NotificationCenter.default.publisher(for: AVAudioSession.routeChangeNotification)
.sink { [weak self] _ in self?.handleChange() }
.store(in: &cancellables) // Auto-cleanup with viewModel
Alternative: NotificationCenter.default.removeObserver(self) in deinit.
Pattern 3: Closure Capture Leaks (15% of leaks)
❌ Leak — Closure in array captures self
updateCallbacks.append { [self] track in
self.refreshUI(with: track) // Strong capture → cycle
}
✅ Fix: Use [weak self]
updateCallbacks.append { [weak self] track in
self?.refreshUI(with: track)
}
Clear callback arrays in deinit. Use [unowned self] only when certain self outlives the closure.
Pattern 4: Strong Reference Cycles
❌ Leak — Mutual strong references
player?.onPlaybackEnd = { [self] in self.playNextTrack() }
// self → player → closure → self (cycle)
✅ Fix: [weak self] in closure
player?.onPlaybackEnd = { [weak self] in self?.playNextTrack() }
Pattern 5: View/Layout Callback Leaks
Use the delegation pattern with AnyObject protocol (enables weak references) instead of closures that capture view controllers.
Pattern 6: PhotoKit Image Request Leaks
PHImageManager.requestImage() returns a PHImageRequestID that must be cancelled. Without cancellation, pending requests queue up and hold memory when scrolling.
class PhotoCell: UICollectionViewCell {
private var imageRequestID: PHImageRequestID = PHInvalidImageRequestID
func configure(with asset: PHAsset, imageManager: PHImageManager) {
if imageRequestID != PHInvalidImageRequestID {
imageManager.cancelImageRequest(imageRequestID)
}
imageRequestID = imageManager.requestImage(for: asset, targetSize: PHImageManagerMaximumSize,
contentMode: .aspectFill, options: nil) { [weak self] image, _ in
self?.imageView.image = image
}
}
how to use axiom-memory-debuggingHow to use axiom-memory-debugging on Cursor
AI-first code editor with Composer
1Prerequisites
Before installing skills in Cursor, ensure your development environment meets these requirements:
- ›Cursor installed and configured on your development machine
- ›Node.js version 16.0+ with npm package manager (verify with
node --version) - ›Active project directory or workspace where you want to add axiom-memory-debugging
2Execute installation command
Execute the skills CLI command in your project's root directory to begin installation:
$npx skills add https://github.com/charleswiltgen/axiom --skill axiom-memory-debuggingThe skills CLI fetches axiom-memory-debugging from GitHub repository charleswiltgen/axiom and configures it for Cursor.
3Select Cursor when prompted
The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:
◆ Which agents do you want to install to?││ ── Universal (.agents/skills) ── always included ────│ • Amp│ • Antigravity│ • Cline│ • Codex│ ●Cursor(selected)│ • Cursor│ • Windsurf4Verify installation
Confirm successful installation by checking the skill directory location:
.cursor/skills/axiom-memory-debuggingReload or restart Cursor to activate axiom-memory-debugging. Access the skill through slash commands (e.g., /axiom-memory-debugging) or your agent's skill management interface.
⚠Security & Verification Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.
Additional Resources
List & Monetize Your Skill
Submit your Claude Code skill and start earning
GET_STARTED →Use Cases▌
User Story & Requirements Generation
Create detailed user stories, acceptance criteria, and feature specs
Example
Generate user stories for 'password reset feature' with acceptance criteria, edge cases, and test scenarios
✓Reduce spec writing time by 50%, ensure comprehensive coverage
Competitive Analysis
Research competitors, compare features, identify gaps
Example
Analyze 5 competitor products, create feature comparison matrix, suggest differentiation opportunities
✓Complete competitive research in 2 hours instead of 2 days
Roadmap Prioritization
Evaluate features using frameworks (RICE, ICE, Kano) and create prioritized backlogs
Example
Score 20 feature ideas using RICE framework, generate prioritized roadmap with rationale
✓Make data-driven prioritization decisions faster
Stakeholder Communication
Draft PRDs, status updates, and stakeholder presentations
Example
Create executive summary of Q3 roadmap, monthly progress report, feature launch announcement
✓Save 3-5 hours/week on communication overhead
Implementation Guide▌
Prerequisites
- ›Claude Desktop or compatible AI client
- ›Access to product documentation and roadmap tools (Jira, Notion, etc.)
- ›Understanding of product management frameworks (RICE, Jobs-to-be-Done, etc.)
- ›Stakeholder contact information and communication channels
Time Estimate
30-60 minutes to see productivity improvements
Installation Steps
- 1.Install product management skill
- 2.Start with user story generation for known feature
- 3.Progress to competitive analysis: research 2-3 competitors
- 4.Use for roadmap prioritization: apply RICE/ICE scoring
- 5.Draft stakeholder communications and refine based on feedback
- 6.Build template library for recurring PM tasks
- 7.Share effective prompts with product team
Common Pitfalls
- ⚠Not validating competitive research—verify facts before sharing
- ⚠Accepting user stories without involving engineering team
- ⚠Over-relying on frameworks without qualitative judgment
- ⚠Not customizing outputs to company culture and communication style
- ⚠Skipping stakeholder validation of generated requirements
Best Practices▌
✓ Do
- +Validate research and competitive analysis with real data
- +Collaborate with engineering when generating technical requirements
- +Customize frameworks and templates to your company context
- +Use skill for first drafts, refine with stakeholder input
- +Document successful prompt patterns for PM tasks
- +Combine AI efficiency with human judgment and intuition
✗ Don't
- −Don't publish competitive analysis without fact-checking
- −Don't finalize user stories without engineering review
- −Don't make prioritization decisions solely on AI scoring
- −Don't skip customer validation of generated requirements
- −Don't ignore company-specific context and culture
💡 Pro Tips
- ★Provide context: company goals, constraints, customer feedback
- ★Ask for alternatives: 'Show 3 ways to prioritize this roadmap'
- ★Request stakeholder-specific formatting: 'Executive summary vs. engineering spec'
- ★Use skill for 70% generation + 30% customization to company needs
When to Use This▌
✓ Use When
Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.
✗ Avoid When
Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.
Learning Path▌
- 1Basic: user stories, feature specs, status updates
- 2Intermediate: competitive analysis, prioritization frameworks, PRDs
- 3Advanced: product strategy, go-to-market planning, OKR setting
- 4Expert: product vision, market positioning, business model innovation
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
general reviewsRatings
4.7★★★★★38 reviews- ★★★★★Mateo Shah· Dec 24, 2024
axiom-memory-debugging reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Ganesh Mohane· Dec 20, 2024
Keeps context tight: axiom-memory-debugging is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Alexander Anderson· Dec 20, 2024
axiom-memory-debugging has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Shikha Mishra· Dec 12, 2024
Solid pick for teams standardizing on skills: axiom-memory-debugging is focused, and the summary matches what you get after install.
- ★★★★★Hassan Martin· Nov 15, 2024
I recommend axiom-memory-debugging for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★Alexander Zhang· Nov 11, 2024
axiom-memory-debugging fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Yash Thakker· Nov 3, 2024
We added axiom-memory-debugging from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Dhruvi Jain· Oct 22, 2024
axiom-memory-debugging fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Amina Kapoor· Oct 6, 2024
Useful defaults in axiom-memory-debugging — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Aanya White· Oct 2, 2024
We added axiom-memory-debugging from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
showing 1-10 of 38
1 / 4