A tiny Windows utility that pins Discord's process priority class to NORMAL and
self-heals it if Discord ever escapes the lock.
By default Discord raises its own process to High priority on Windows, which can cause FPS drops in games and stutters. DiscordLock prevents Discord from ever raising its priority above Normal and continuously keeps it there.
DiscordLock.exe is a single ~800 KB static binary (one source file, discordlock.cpp).
It does not launch Discord itself. Instead it runs as a persistent background watcher.
-
Locked job object — On startup
CreatePriorityJob()creates a job object and setsJOB_OBJECT_LIMIT_PRIORITY_CLASSwithNORMAL_PRIORITY_CLASS. Any process assigned to the job is held at Normal priority by the OS. -
Watch loop —
main()enters an infinite loop, sleeping 500 ms between checks (≈0% CPU impact). -
Detect & relaunch —
MonitorAndLock()walks all processes viaCreateToolhelp32Snapshot. For everyDiscord.exethat is not already inside the locked job, it:- kills the unlocked process (
KillAllDiscordProcesses()→TerminateProcess), - waits 500 ms for Windows to release handles,
- relaunches Discord through the installer stub so it attaches to the locked job
(
LaunchLockedDiscord→Update.exe --processStart Discord.exe, createdCREATE_SUSPENDED, thenAssignProcessToJobObject+ResumeThread).
- kills the unlocked process (
Processes that are already in the job are left untouched.
Requires a C++17-capable compiler (tested with g++).
g++ -O2 -mwindows -static -static-libgcc -static-libstdc++ -o DiscordLock.exe DiscordLock.cpp
Flags:
-O2— optimization-mwindows— no console window-static/-static-libgcc/-static-libstdc++— fully self-contained binary
- Compile (see above).
- Run
DiscordLock.exe. - Launch Discord normally from your desktop/taskbar. DiscordLock detects it, attaches it to the locked job, and keeps it at Normal priority.
DiscordLock does not need to be started first — it waits for you to launch Discord.
- Windows only (uses Win32 job objects, Toolhelp snapshots).
- Discord must be installed normally so that
%LOCALAPPDATA%\Discord\Update.exeexists — the relaunch path invokesUpdate.exe --processStart Discord.exe. If that path is missing, Discord cannot be relaunched through the locked job. - Discord is terminated and relaunched on every cycle where it is found outside the job (e.g. after a crash, update, or manual launch that bypassed the lock). This is the "lock" cost: not CPU, but a kill/relaunch event.
| File | Purpose |
|---|---|
discordlock.cpp |
Entire program (one translation unit) |
DiscordLock.exe |
Compiled binary (git-ignored) |
Key functions in discordlock.cpp:
CreatePriorityJob()— build the Normal-priority job object.KillAllDiscordProcesses()— terminate everyDiscord.exe.LaunchLockedDiscord(HANDLE)— relaunch Discord attached to the job.MonitorAndLock(HANDLE)— one scan/relaunch cycle.main()— create job + persistent watch loop.