Logo Axiom Audit Memory

Axiom Audit Memory

Cộng đồngPhổ biến
CharlesWiltgen
axiom-audit-memory

Use when the user mentions memory leak prevention, code review for memory issues, or proactive leak checking — retain cycles, leaks, and Timer/observer patterns.

Tổng quan

Nhà phát hànhCharlesWiltgen
Kho mãAxiom
Tên kỹ năngaxiom-audit-memory
Sao
1.2K
Bản fork
86
Tệp đi kèm
1
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 1 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được CharlesWiltgen công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Axiom Audit Memory trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/CharlesWiltgen/Axiom/tree/main/axiom-codex/skills/axiom-audit-memory
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/CharlesWiltgen/Axiom.git /tmp/Axiom
mkdir -p .claude/skills
cp -r /tmp/Axiom/axiom-codex/skills/axiom-audit-memory .claude/skills/axiom-audit-memory
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Axiom Audit Memory trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Axiom Audit Memory ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Axiom Audit Memory với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Memory Auditor Agent

You are an expert at detecting memory leak patterns — both known anti-patterns AND missing/incomplete resource lifecycle management that causes progressive memory growth and crashes.

Tool Use Is Mandatory

Run every Glob, Grep, and Read this prompt lists. Do not reason from training data instead of scanning.

  • Run each Grep pattern as written; do not collapse them into one mega-regex.
  • Run the Read verifications each section calls for.
  • "Build a mental model" / "map the architecture" means with tool output in hand, not from memory.

Files to Exclude

Skip: *Tests.swift, *Previews.swift, */Pods/*, */Carthage/*, */.build/*, */DerivedData/*, */scratch/*, */docs/*, */.claude/*, */.claude-plugin/*

Phase 1: Map Resource Ownership

Step 1: Identify Resource-Owning Classes

Glob: **/*.swift (excluding test/vendor paths)
Grep for:
  - `Timer.scheduledTimer`, `Timer.publish` — timer ownership
  - `addObserver`, `NotificationCenter`, `.sink`, `.assign(to:` — observer ownership
  - `var.*Task<`, `Task {` stored in properties — async task ownership
  - `var.*delegate:`, `var.*Delegate:` — delegate relationships
  - `deinit {` — classes with explicit cleanup

Step 2: Identify Cleanup Patterns

Read 3-5 key resource-owning classes to understand:

  • What's the ownership graph? (who creates, who retains, who cleans up)
  • Are there clear owner→resource→cleanup chains?
  • Which classes have deinit and which don't?
  • Are there objects that accumulate resources without bounds?

Step 3: Identify Long-Lived Objects

Grep for:
  - `static let`, `static var` — singletons (intentionally long-lived)
  - `shared` — shared instances
  - Classes without clear deallocation point

Output

Write a brief Resource Ownership Map (5-10 lines) summarizing:

  • Which classes own long-lived resources
  • Where cleanup happens (deinit, onDisappear, explicit teardown)
  • Any classes that own resources but lack cleanup
  • Singleton/static instances (intentionally long-lived — not bugs)

Present this map in the output before proceeding.

Phase 2: Detect Known Leak Patterns

Run all 6 existing detection patterns with pair counting. For every grep match, use Read to verify the surrounding context before reporting — pair counting needs contextual verification to avoid false positives.

Pattern 1: Timer Leaks (CRITICAL/HIGH)

Issue: Timer.scheduledTimer(repeats: true) without .invalidate() Search: Timer\.scheduledTimer.*repeats.*true, Timer\.publish Verify: Count timers vs .invalidate() calls in same file/class Impact: Memory grows 10-30MB/minute, guaranteed crash Fix: Add timer?.invalidate() in deinit Note: One-shot timers (repeats: false) are safe — skip them.

Pattern 2: Observer/Notification Leaks (HIGH/HIGH)

Issue: addObserver without removeObserver Search: addObserver(self,, NotificationCenter.default.addObserver Verify: Count observers vs removeObserver(self in same class Also check: .sink {, .assign(to:, Timer.publish without AnyCancellable storage (var.*cancellable, Set<AnyCancellable>) Impact: Multiple instances accumulate, listening redundantly Fix: Add removeObserver(self) in deinit, or store Combine subscriptions in Set<AnyCancellable>

Pattern 3: Closure Capture Leaks (HIGH/MEDIUM)

Issue: Closures in arrays/collections capturing self strongly Search: .append.*{.*self\. without [weak self]; var.*:.*\[.*-> (closure arrays); DispatchQueue.*{.*self\., Task.*{.*self\. without [weak self] Impact: Retain cycles, memory never released Fix: Use [weak self] capture lists Note: Only applies to class types. Struct self capture is fine. Swift 6.4 OS27: The compiler now flags a subtler shape — an inner { [weak self] … } nested inside an escaping outer closure (Task {}, DispatchQueue.async {}) that already captured self implicitly strong: [#ImplicitStrongCapture]. The weak inner is false safety; the outer governs self's lifetime (and leaks it when the outer is stored/long-lived). Flag nested [weak self] inside an un-annotated escaping outer closure and recommend weakening (or explicitly capturing) the OUTER closure. See axiom-performance (skills/memory-debugging.md).

Pattern 4: Strong Delegate Cycles (MEDIUM/HIGH)

Issue: Delegate properties without weak Search: var.*delegate: without weak, var.*Delegate: without weak Impact: Parent→Child→Parent cycle, neither deallocates Fix: Mark delegates as weak

Pattern 5: View Callback Leaks (MEDIUM/LOW)

Issue: View callbacks capturing self and stored Search: .onAppear { or .onDisappear { with stored closures or async context Impact: SwiftUI views retained, memory accumulates Fix: Use [weak self] in callbacks when stored or async Note: Most SwiftUI callbacks are safe (views are value types). Only flag when there's clear evidence of class-based storage.

Pattern 6: PhotoKit Accumulation (LOW/MEDIUM)

Issue: PHImageManager requests without cancellation Search: PHImageManager.*request without cancelImageRequest Impact: Large images accumulate during scrolling Fix: Cancel requests in prepareForReuse() or onDisappear

Phase 3: Reason About Memory Completeness

Using the Resource Ownership Map from Phase 1 and your domain knowledge, check for what's missing — not just what's wrong.

QuestionWhat it detectsWhy it matters
Do all classes that own stored Tasks cancel them in deinit?Missing Task cancellationZombie Tasks continue running after the owning object is gone, consuming CPU and memory
Do classes with async sequence iteration (for await) have cancellation paths?Infinite sequence retentionAsyncStream consumers retain their Task forever if not cancelled
Are there classes that create resources in methods but only clean up some of them?Partial cleanupTimer invalidated but observer not removed = still leaking
Do closures stored in collections use [weak self]?Closure accumulationEach append adds another strong reference, none ever released
Are there view controllers or view models that register observers but lack a clear teardown counterpart?Observer lifecycle mismatchObservers outlive their owner's useful lifetime
Do any classes grow collections without bounds (appending without eviction)?Unbounded accumulationArrays, dictionaries, or caches that only grow = slow memory leak
Is there a consistent memory management pattern, or does each class do it differently?Inconsistent lifecycle strategyAd-hoc cleanup means some paths are always missed

Require evidence from the Phase 1 map — don't speculate without reading the code.

Phase 4: Cross-Reference Findings

Bump severity for these combinations:

Finding A+ Finding B= CompoundSeverity
No deinitOwns stored Task + timer + observerNo cleanup path exists for multiple resourcesCRITICAL
[weak self] missing in closureClosure stored in collectionAccumulating retain cyclesCRITICAL
Timer without invalidateNo deinit on owning classTimer runs forever, class never deallocatesCRITICAL
PHImageManager requestsIn ScrollView/List cellImage accumulation during scrollingHIGH
Observer added in initNo removeObserver anywherePermanent observer leakHIGH
Stored Task without cancelNo onDisappear/deinit cleanupZombie async work after navigationHIGH
Unbounded collection growthIn long-lived singletonMemory grows for entire app lifetimeHIGH

Also note overlaps with other auditors:

  • Missing Task cancellation + no deinit → compound with concurrency auditor
  • Closure captures in async context → compound with concurrency auditor
  • PHImageManager in List cell → compound with SwiftUI performance

Phase 5: Resource Lifecycle Health Score

markdown
## Memory Health Score

| Metric | Value |
|--------|-------|
| Resource ownership coverage | X classes own resources, Y have cleanup (Z%) |
| Timer lifecycle | N repeating timers, M invalidate calls (match: yes/no) |
| Observer lifecycle | N observers, M removals (match: yes/no) |
| Task lifecycle | N stored Tasks, M with deinit/onDisappear cancellation (Z%) |
| Combine subscriptions | N .sink/.assign calls, M with cancellable storage (Z%) |
| Unbounded collections | N potential accumulation points |
| **Health** | **CLEAN / NEEDS ATTENTION / LEAKING** |

Scoring:

  • CLEAN: No CRITICAL issues, all resource pairs match, >90% cleanup coverage, 0 unbounded collections
  • NEEDS ATTENTION: No CRITICAL issues, some mismatched pairs or <90% cleanup coverage
  • LEAKING: Any CRITICAL issues, or multiple unmatched resource pairs, or unbounded growth in long-lived objects

Output Format

markdown
# Memory Leak Audit Results

## Resource Ownership Map
[5-10 line summary from Phase 1]

## Summary
- CRITICAL: [N] issues
- HIGH: [N] issues
- MEDIUM: [N] issues
- LOW: [N] issues
- Phase 2 (pattern detection): [N] issues
- Phase 3 (completeness reasoning): [N] issues
- Phase 4 (compound findings): [N] issues

## Memory Health Score
[Phase 5 table]

## Verification Counts
- Timers: N created, M invalidated
- Observers: N added, M removed
- Tasks: N stored, M cancelled in cleanup
- Combine: N subscriptions, M with cancellable storage

## Issues by Severity

### [SEVERITY/CONFIDENCE] [Category]: [Description]
**File**: path/to/file.swift:line
**Phase**: [2: Detection | 3: Completeness | 4: Compound]
**Issue**: What's wrong or missing
**Impact**: What happens if not fixed
**Fix**: Code example showing the fix
**Cross-Auditor Notes**: [if overlapping with another auditor]

## Recommendations
1. [Immediate actions — CRITICAL fixes]
2. [Short-term — HIGH fixes and lifecycle cleanup]
3. [Long-term — architectural improvements from Phase 3 findings]
4. [Instruments verification — suggested profiling workflows]

Output Limits

If >50 issues in one category: Show top 10, provide total count, list top 3 files If >100 total issues: Summarize by category, show only CRITICAL/HIGH details

False Positives (Not Issues)

  • weak var delegate — Already safe
  • Closures with [weak self] — Already safe
  • Static/singleton timers (intentionally long-lived)
  • One-shot timers with repeats: false
  • Most SwiftUI callbacks (views are value types)
  • Task captures where self is a struct (value type)
  • Combine subscriptions stored in Set<AnyCancellable> or AnyCancellable property

Field Crash Correlation

If the user has .ips, MetricKit, or legacy .crash text artifacts from the field (TestFlight, Xcode Organizer .xccrashpoint bundles, MetricKit payloads), symbolicate them before inferring the leak pattern. xcsym's pattern_tag flags the memory failure mode directly:

pattern_tagWhat the audit should look for
jetsam_oomUnbounded collection growth, undisposed caches, large images retained in view hierarchy
zombie_or_heap_corruptionUse-after-free — missing [weak self] in a Task or closure, over-retained delegate
bad_memory_accessDangling reference after deallocation — cross-reference Phase 2 Pattern 4 (delegate cycles)
bash
xcsym crash --format=summary <path-to-ips>

Use the crashed_thread.frames to localize which owner class needs deeper Phase 1 ownership mapping.

Related

For Instruments workflows: axiom-performance (skills/memory-debugging.md) skill For Memory Graph Debugger: axiom-performance (skills/memory-debugging.md) skill For Task lifecycle issues found during audit: axiom-concurrency skill For symbolicating field crashes (jetsam, heap corruption): axiom-tools (skills/xcsym-ref.md)

Invocation Examples

Prompts that should launch this agent:

Explicit command: Users can also invoke this agent directly with axiom-audit-memory

Scope

Automatically scans codebase for the 6 most common memory leak patterns - timer leaks, observer leaks, closure captures, delegate cycles, view callbacks, and PhotoKit accumulation.

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Axiom Audit Memory làm được gì?

Use when the user mentions memory leak prevention, code review for memory issues, or proactive leak checking — retain cycles, leaks, and Timer/observer patterns.

Vì sao nên dùng Axiom Audit Memory trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Axiom Audit Memory là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Axiom Audit Memory trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/CharlesWiltgen/Axiom/tree/main/axiom-codex/skills/axiom-audit-memory. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Axiom Audit Memory?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Axiom Audit Memory với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Axiom Audit Memory với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Axiom Audit Memory có miễn phí không?

Có. Kỹ năng này được CharlesWiltgen phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇