Back to Skills

rxswift-memory-check

verified

Quick RxSwift memory leak detection for iOS. Finds missing dispose bags, retain cycles, and strong self references. Use when debugging memory issues, checking Observable subscriptions, or investigating retain cycles in RxSwift code.

View on GitHub

Marketplace

py-claude-marketplace

daispacy/py-claude-marketplace

Plugin

py-plugin

Repository

daispacy/py-claude-marketplace

py-plugin/skills/rxswift-memory-check/SKILL.md

Last Verified

January 20, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/daispacy/py-claude-marketplace/blob/main/py-plugin/skills/rxswift-memory-check/SKILL.md -a claude-code --skill rxswift-memory-check

Installation paths:

Claude
.claude/skills/rxswift-memory-check/
Powered by add-skill CLI

Instructions

# RxSwift Memory Leak Detector

Fast, focused check for RxSwift memory management issues in iOS code.

## When to Activate

- "memory leak", "retain cycle", "dispose bag"
- "RxSwift memory issues", "check subscriptions"
- "[weak self]", "memory management"
- Debugging memory problems or crashes

## Quick Check Process

### Step 1: Find RxSwift Subscriptions

Use Grep to locate all Observable subscriptions:
- Pattern: `\.subscribe\(`
- Check surrounding code for proper disposal

### Step 2: Verify Each Subscription

For every `.subscribe(`:
1. โœ… Has `.disposed(by: disposeBag)`
2. โœ… Uses `[weak self]` or `[unowned self]` in closures
3. โœ… DisposeBag is a property, not local variable

### Step 3: Check Common Patterns

#### ๐Ÿ”ด Pattern 1: Missing Disposal
```swift
viewModel.data
    .subscribe(onNext: { data in })
    // MISSING: .disposed(by: disposeBag)
```

#### ๐Ÿ”ด Pattern 2: Retain Cycle
```swift
viewModel.data
    .subscribe(onNext: { data in
        self.updateUI(data)  // Strong self!
    })
```

#### ๐Ÿ”ด Pattern 3: Local DisposeBag
```swift
func loadData() {
    let disposeBag = DisposeBag()  // Local variable!
    // Cancels immediately when function ends
}
```

### Step 4: Generate Report

Focused report with:
- Critical issues by severity
- File locations and line numbers
- Current vs. fixed code
- Impact assessment
- Recommended fixes

## Search Patterns

### Find subscriptions without disposal
```
Pattern: \.subscribe\(
Context: Check next 5 lines for .disposed
```

### Find strong self references
```
Pattern: subscribe.*\{[^[]*self\.
Context: -A 3 -B 1
```

### Find local DisposeBag declarations
```
Pattern: let disposeBag = DisposeBag\(\)
```

## Output Format

```markdown
# RxSwift Memory Check Report

## Critical Issues: X

### 1. Missing Disposal - MEMORY LEAK
**File**: `PaymentViewModel.swift:45`
**Risk**: Memory accumulation, eventual crash

**Current**:
```swift
// Missing disposal
```

**Fix**:
```swift
.disposed(by: disposeBag)
```

**Impact**: [Exp

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
3013 chars