1
lzrdblzzrd 0e8d7333c1 Rewrite: simplify to strict algorithm, remove promoted map
- Remove promoted map entirely — processes are demoted when RSS < -mem
  and promoted when RSS >= -mem, no permanent state
- Remove trySetPrio closure — use setPrio directly for simplicity
- Remove curPrioWithHandle helper — inline procGetPriority.Call
- Remove GAME ... tracked as game (blocked) repeated log — log once
  on detection via GAME DETECT, silently skip on subsequent scans
- Game mode: log GAME DETECT once when process first exceeds game-mem
- gameSaved stores original priority before IDLE demote, restores on
  GAME MODE OFF or shutdown
- Delay between priority changes: 100ms
- Delete TZ.md (was a test for other AI)
2026-06-23 11:16:51 +03:00

autoPriority

Monitors process memory usage on Windows and automatically adjusts CPU priority: promotes memory-heavy processes to HIGH and demotes everything else to NORMAL. Optionally enters Game Mode when a process exceeds a higher threshold, boosting it to HIGH and setting all other processes to IDLE.

Windows only.

How it works

Normal mode

Every scan interval the program iterates over all running processes:

RSS vs -mem Current priority Action
≥ threshold anything except HIGH → HIGH (logged as PROMOTE)
≥ threshold already HIGH skip
< threshold ABOVE_NORMAL, HIGH, or REALTIME → NORMAL (logged as DEMOTE)
< threshold NORMAL, BELOW_NORMAL, or IDLE skip

Game mode (-game-mem)

When any process reaches or exceeds the -game-mem threshold:

  1. That process → HIGH (logged as GAME)
  2. All other processes → IDLE
  3. Log: GAME MODE ON

When all such processes close:

  1. All processes that were demoted during game mode are restored to their original priority (logged as RESTORE)
  2. GAME MODE OFF logged
  3. Normal mode resumes — priorities recalculated by -mem rules

If SetPriorityClass or OpenProcess fails for a process (e.g., anti-cheat protection, system processes), the process is added to an in-memory exclusion list and never touched again (logged as BLOCK). When the process exits, it is automatically removed from the list.

On shutdown, all processes are restored: game-mode demoted processes to their saved original priority, promoted and game processes to NORMAL.

Build

Requires Go 1.26+.

# Standard build (with console window)
go build -o autopriority.exe .

# Background build (no console, minimal size)
go build -ldflags="-H windowsgui -s -w" -o autopriority.exe .

Usage

autopriority [flags]
Flag Default Description
-mem 512M Memory threshold (e.g. 512M, 1G, 2048M)
-game-mem 4G Game threshold (e.g. 3G, 4G). Must be > -mem. 0 = disabled
-interval 1 minute Scan interval (min 10s)
-dry-run false Log only, don't change priority

Examples:

# Run with 1 GB threshold, scanning every 30 seconds
autopriority -mem=1G -interval=30s

# Run with defaults (512M threshold, 4G game threshold)
autopriority

# Game mode: normal threshold 512M, game threshold 4G
autopriority -mem=512M -game-mem=4G

# Dry run — log decisions without changing anything
autopriority -dry-run

Log

Log is always written to %TEMP%\autopriority.log. A new log file is created on each run (previous log is deleted).

Log entries:

Prefix Meaning
PROMOTE Priority raised to HIGH (normal mode)
DEMOTE Priority lowered to NORMAL (normal mode)
GAME Process set to HIGH or IDLE (game mode)
GAME MODE ON Game mode activated
GAME MODE OFF Game mode deactivated — processes restored
BLOCK OpenProcess or SetPriorityClass failed; process added to exclusion list
RESTORE Process restored to original/saved priority (game mode exit or shutdown)
SKIP RESTORE PID reused by a different process; restore skipped
[DRY-RUN] Would change priority (dry-run mode)

Auto-start

Open Win+R, type shell:startup, and press Enter. Then place a shortcut to autopriority.exe in the folder that opens.

Dependencies

None. Uses only Windows API (kernel32, psapi) via raw syscall.

S
Description
A program that automatically sets a high priority for game processes
Readme 86 KiB
Languages
Go 100%