Skip to content

Conversation

@PoomSmart
Copy link

@PoomSmart PoomSmart commented Dec 14, 2025

Problem

ipsw diff consumed 48GB+ RAM, crashing on 16GB and lower memory machines.

Changes

This PR contains improvements for in-memory diffing and the addition of disk-cached diffing.

1. Streaming DMG Traversal (internal/search/search.go)

  • File paths are now streamed directly to handlers instead of collecting into []string slices
  • Eliminates gigabytes of path string accumulation for large DMGs

2. Per-Image DSC Diff (internal/commands/dsc/diff.go)

  • Diff images one-at-a-time instead of building two huge map[string]*DiffInfo maps
  • Close MachO handles immediately after comparison

3. Optional Disk Caching (internal/commands/macho/diff.go)

  • Added --low-memory flag for low memory machines
  • Default: fast in-memory mode (original behavior)
  • Low-memory: caches old IPSW's DiffInfo to temp gob files, loads on-demand

4. Stream gob.Encode (internal/diff/diff.go)

  • Save() now streams directly to file instead of buffering in bytes.Buffer

Usage

# Default (fast, needs large amount of RAM)
ipsw diff old.ipsw new.ipsw -o out -m

# Low-memory mode (slower, works on low memory machine)
ipsw diff old.ipsw new.ipsw -o out -m --low-memory

Fixes #985

@PoomSmart PoomSmart marked this pull request as ready for review December 20, 2025 04:35
@blacktop
Copy link
Owner

Have you done a speed comparison between low-memory and normal mode? or are you not able to due to the limitations of your host?

@PoomSmart
Copy link
Author

@blacktop Yeah unfortunately I cannot perform normal mode test. My machine just doesn't have enough RAM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ipsw diff is taking too much memory

2 participants