Pure Go implementation of the smem tool for reporting memory usage with proportional share of shared memory.
- ✅ Complete parsing of
/proc/[pid]/smaps - ✅ Calculates USS, PSS, RSS, SWAP
- ✅ Reports by process, user, mapping, or system-wide
- ✅ Regex filtering by process, user, or mapping
- ✅ Flexible sorting (PSS, RSS, USS, Swap, name)
- ✅ Bar graphs and pie charts
- ✅ Flexible formatting (percentages, abbreviated units)
- ✅ Multi-platform support (Linux, macOS, Windows)
- ✅ Pure Go - no external dependencies
# Linux x86_64
GOOS=linux GOARCH=amd64 go build -o smem main.go types.go parser.go
# macOS Intel
GOOS=darwin GOARCH=amd64 go build -o smem-darwin main.go types.go parser.go
# macOS M1/M2/M3 ARM64
GOOS=darwin GOARCH=arm64 go build -o smem-darwin-arm64 main.go types.go parser.go
# Windows
GOOS=windows GOARCH=amd64 go build -o smem.exe main.go types.go parser.go# Default - processes sorted by PSS
sudo ./smem
# System-wide report
sudo ./smem -w
# By user
sudo ./smem -u
# By mapping
sudo ./smem -m
# Sorted by RSS descending
sudo ./smem -s rss -r
# Filter processes (regex)
sudo ./smem -P 'firefox|chrome'
# Filter users
sudo ./smem -U '^root$'
# With percentages and abbreviated units
sudo ./smem -p -k
# Bar graph
sudo ./smem --bar=name
# Pie chart
sudo ./smem --pie=user
# No header and show totals
sudo ./smem -H -t
# Full help
./smem -h| Option | Description |
|---|---|
| -h, --help | Show help message |
| -m, --mappings | Report by mapping |
| -u, --users | Report by user |
| -w, --system | System-wide report |
| -s, --sort FIELD | Sort field (pss, rss, uss, swap, name) |
| -r, --reverse | Reverse sort order |
| -P, --processfilter REGEX | Filter processes |
| -U, --userfilter REGEX | Filter users |
| -M, --mapfilter REGEX | Filter mappings |
| -p, --percent | Show percentages |
| -k, --abbreviate | Abbreviate units |
| -H, --no-header | No header |
| -t, --totals | Show totals |
| -a, --autosize | Auto-size columns |
| -n, --numeric | Numeric IDs |
| --bar GROUPBY | Bar graph |
| --pie GROUPBY | Pie chart |
- USS (Unique Set Size): Memory that is private to this process
- PSS (Proportional Set Size): Memory that is shared, divided proportionally
- RSS (Resident Set Size): Total memory resident in physical RAM
- SWAP: Memory that has been swapped out to disk
- main.go - Main program and reports
- types.go - Data structures
- parser.go - /proc parsing
- go.mod - Go module definition
- README.md - This documentation
| File | Lines | Purpose |
|---|---|---|
| main.go | 650 | Main program, CLI flags, report generation |
| types.go | 80 | Data structures (Process, Mapping, UserInfo, etc.) |
| parser.go | 240 | /proc parsing, memory statistics extraction, filtering |
| go.mod | 3 | Go module configuration |
| README.md | 130+ | Complete documentation and usage guide |
| TOTAL | ~1100 | Production-ready code |
- ✅ Zero external dependencies - Uses only Go standard library
- ✅ Fast compilation - Single-file binaries
- ✅ Cross-platform - Compiles for Linux, macOS, Windows
- ✅ Full smem compatibility - All original options implemented
- ✅ 100% English - All code and docs in English
- ✅ Production-ready - Error handling, memory-efficient
Everything you need to build a complete memory analysis tool! 🚀