원클릭으로
macos-memory
macOS native memory analysis tools (leaks, heap, vmmap, Instruments). Use for native app memory debugging.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
macOS native memory analysis tools (leaks, heap, vmmap, Instruments). Use for native app memory debugging.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Create a git worktree for a new TASK. Use when starting a new feature, fix, or refactor task that requires isolated development.
Go code quality rules and standards for kattle project. Apply when writing or reviewing Go code.
Memory profile snapshot capture and baseline comparison. Use for verification after memory optimization.
Go application memory profiling and analysis. Use when investigating memory leaks or high memory usage.
React/TypeScript code quality rules for kattle frontend. Apply when writing or reviewing frontend code.
Run Go and frontend tests for kattle project. Use after code changes to verify correctness.
| name | macos-memory |
| description | macOS native memory analysis tools (leaks, heap, vmmap, Instruments). Use for native app memory debugging. |
| disable-model-invocation | true |
| user-invocable | true |
| allowed-tools | Bash, Read |
Comprehensive guide for analyzing memory usage and detecting leaks in native macOS applications using Apple's native profiling tools.
The leaks tool detects unreachable memory allocations that have been leaked.
leaks <pid>
Check a running process for memory leaks:
leaks 1234
Run an application and automatically check for leaks when it exits:
leaks --atExit -- ./myapp
leaks --atExit -- /path/to/binary arg1 arg2
leaks <pid> - Check running processleaks --atExit -- <command> - Check application at exitleaks --nocontext - Suppress stack trace contextleaks --nostacks - Don't print stack traces (faster)The tool will report:
The heap tool provides detailed information about heap memory allocations.
heap <pid>
Show heap summary:
heap 1234
heap <pid> -addresses all
Dump all allocation addresses (detailed, slow for large heaps):
heap 1234 -addresses all
heap <pid> - Show heap summaryheap <pid> -addresses all - Show all individual allocationsheap <pid> -addresses <size> - Show allocations above a certain sizeheap <pid> -diffFrom <file> - Compare heap to a previous snapshotThe vmmap tool shows the complete virtual memory map of a process, including all memory regions and their usage.
vmmap <pid>
Show full virtual memory map:
vmmap 1234
vmmap <pid> | grep MALLOC
Common memory region types in output:
vmmap 1234 | grep -E "MALLOC|TOTAL"
Shows only malloc regions and totals for quick overview.
The xcrun instruments command-line tool provides professional profiling capabilities.
Detect memory leaks while capturing detailed information:
xcrun instruments -t "Leaks" ./myapp
xcrun instruments -t "Leaks" -l 30000 ./myapp
Track all memory allocations:
xcrun instruments -t "Allocations" ./myapp
xcrun instruments -t "Allocations" -l 30000 ./myapp
-t "Name" - Instrument template to use-l <duration> - Recording duration in milliseconds-o <path> - Output file path (.trace format)-s <delay> - Start delay in milliseconds-p <PID> - Attach to running processCommon instruments for memory analysis:
xcrun instruments -t "Leaks" -o /tmp/myapp.trace ./myapp
Results can be opened in Instruments.app for GUI analysis.
Find process by partial name match:
pgrep -f kattle
pgrep -f "kattle.*--flag"
Get first matching PID:
pgrep -f kattle | head -1
Alternative method with ps:
ps aux | grep kattle
ps aux | grep -i "MyApp"
Extract PID from ps output:
ps aux | grep kattle | grep -v grep | awk '{print $2}'
open -a Activity\ Monitor
PID=$(pgrep -f kattle | head -1)
echo "Process: kattle (PID: $PID)"
ps -o rss= -p $PID | awk '{printf "RSS: %.2f MB\n", $1/1024}'
PID=$(pgrep -f myapp | head -1)
echo "=== Leak Detection ==="
leaks $PID
echo "=== Heap Summary ==="
heap $PID
echo "=== Top Malloc Regions ==="
vmmap $PID | grep -i malloc | head -10
# Start profiling with Leaks instrument
xcrun instruments -t "Leaks" -o /tmp/profile.trace ./myapp
# Open results in Instruments.app
open /tmp/profile.trace
PID=$(pgrep -f myapp | head -1)
# Capture initial heap snapshot
heap $PID > /tmp/heap_initial.txt
# Wait for activity
sleep 10
# Compare with second snapshot
heap $PID -diffFrom /tmp/heap_initial.txt
sudo for privileged processesIf tools aren't in PATH, use full paths:
/usr/bin/leaks <pid>
/usr/bin/heap <pid>
/usr/bin/vmmap <pid>
Need appropriate privileges for some processes:
sudo leaks <pid>
sudo xcrun instruments -t "Leaks" ./app
Ensure Xcode command line tools are installed:
xcode-select --install