Skip to content
raihanworldPublic

About

Live monitor for Windows kernel pool memory: graphs, every pool tag by size or growth, move paged pool out of RAM by hand or on a schedule, and a switch for the Windows 11 token leak.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

PoolWatch

A live monitor for Windows kernel pool memory. Watch it grow, see which pool tag is growing, and push the pageable part out of RAM without a restart.

Latest release License: MIT Windows 10 and 11, x64 One 340 KB exe

PoolWatch's Monitor view: six live graphs and a breakdown of 16.9 GB of kernel pool

The Monitor view, drawn with the built-in demo data (--shot --demo), which is modelled on the real case below.

"Paged pool" and "Non-paged pool" in Task Manager are memory that Windows and its drivers keep for themselves. When a driver or Windows itself leaks, those two numbers climb for days, "In use" climbs with them, and no process in the list accounts for it. The PC gets slower until you restart.

PoolWatch is one small exe that shows what is happening in there, live:

  • Six graphs on one time axis: paged pool (and how much of it is in RAM), non-paged pool, token leak rate, memory in use, commit and CPU, over the last minute to the last two hours.
  • Every pool tag, by size or by growth, with plain names for the common ones. Sorting by growth points at a leak in about a minute. No Windows Driver Kit needed.
  • Move out of RAM: one button (or a schedule) that pushes pageable kernel memory out to the pagefile, the same action as RAMMap's Empty Working Sets.
  • A switch for the Windows 11 token leak, kept on for you across sign-ins. See the status note below before you use it.

It lives in the notification area, costs about 2 ms of processor time per second while you are looking at it, and never uses the network.

Status of the Windows 11 token leak (30 November 2026). Microsoft has fixed it. The Windows Terminal team confirmed in microsoft/terminal#20781 that update KB5132057 (build 26200.10075 and 26300.10075) contains the fix. If you can install that update, do: it is the real cure, and then you do not need the workaround switch. PoolWatch remains useful for seeing whether you have the leak at all, for holding it down until you can update, and for the next leak, whatever causes it.

Download

PoolWatch.exe from the latest release: one 340 KB file, no installer.

  • Needs 64-bit Windows 10 or 11. The .NET Framework it uses is part of Windows.
  • Monitoring needs no administrator rights. Only Move out of RAM does, and Windows asks you when it comes to that.
  • The file is not signed, so SmartScreen warns the first time: choose More info, then Run anyway. If you would rather not run a downloaded exe, build it yourself in a few seconds with the compiler Windows already has.
  • The first run adds it to your startup apps. Settings → Start with Windows undoes that.

Built and tested on one PC so far: Windows 11 Pro 25H2 (build 26200), 64 GB of RAM, 32 logical processors. Reports from other versions of Windows are welcome.

What it found on that PC

Seventy-nine hours after a restart, on a PC that runs coding agents, test suites and Docker all day (28 November 2026). These two pictures are the real window, not demo data.

The real Monitor view at 17.2 GB of kernel pool with 3,710,651 tokens held

The real Pool tags view: Toke 6.41 GB, File 3.18 GB, SeAt 1.33 GB

17.2 GB of kernel pool on a 64 GB machine, and the Pool tags view says where it went:

Tag What it is Objects Size
Toke token objects 3,710,643 6.41 GB
SeAt token attributes 14,850,992 1.33 GB
SeTd token dynamic parts 3,710,643 510 MB
SeTl token locks 3,710,643 453 MB
SeDt token attribute table 3,703,898 283 MB
File file objects 8,526,840 3.18 GB
D2d device name strings 8,337,212 254 MB

Two separate leaks, both paid per process start, and that PC had started more than 8 million processes in those 79 hours:

  1. The Windows 11 token leak: 3.7 million access tokens that were never freed, about 2.6 KB each across five tags, 9.0 GB in all. This is the bug tracked in git-for-windows/git#6471 and microsoft/terminal#20781.
  2. A graphics driver: one File object and one D2d string left behind on every process start, 3.4 GB in all. A pool trace (wpr with pool tags) put the allocations in amdkmdag.sys, the driver of the processor's built-in Radeon graphics (version 32.0.21045.1000 on that PC). Disabling that unused device in Device Manager took the growth of D2d from about 2,500 a minute to zero.

Starting a process had become slow as well: cmd /c exit took a median of 38 to 75 ms with the 3.7 million tokens in place, against 8 ms an hour after the restart. Other work was running at the time, so treat that pair as an indication only.

What helped, measured

The token-leak workaround. Same PC, same background workload (a test suite starting 35 to 55 processes a second), one-minute windows a few minutes apart:

Focus timeout Processes started Tokens left behind Per process Per second
Windows' own value (2147483647) 2,214 1,262 0.57 20.8
0, first minute 3,301 144 0.044 2.4
0, second minute 2,986 112 0.038 1.8

That is 93% fewer tokens left behind per process start.

Move out of RAM. It frees RAM for a while; it does not shrink the pool (nothing but a restart does), and programs take back the memory they use within minutes.

Run Paged pool in RAM Memory in use
RAMMap's Empty Working Sets, for reference, with 11.1 GB of paged pool 11.1 GB → about 2 GB not recorded
PoolWatch's button, with a permission prompt 2,800 MB → 902 MB 31,150 MB → 27,565 MB
PoolWatch's button, through its scheduled task, no prompt 1,882 MB → 402 MB 30,519 MB → 25,310 MB
Eight scheduled runs, on average 1,818 MB → 855 MB 1,469 MB lower each time

Leaked memory stays out once it has been moved, because nothing ever touches it again. Memory that Windows is really using comes back: after those scheduled runs, 0.8 to 1.2 GB had returned five minutes later. That is why a run is skipped when little is in RAM.

After the restart, with the workaround on. Ninety minutes in, the real window read 2.51 GB of kernel pool, 6,390 tokens held and "Not leaking". Over the following 41 hours the scheduled check ran 135 times and never found more than 1,448 MB of paged pool in RAM, so it never had to move anything. The workload was lighter than in the 79 hours before, so this shows the pool staying flat, not how much of that is the workaround's doing; the table above does that.

The real Monitor view after the restart: 2.51 GB of kernel pool, not leaking

What I could not do is make the token leak appear on demand. On 30 November I ran about 15,000 Git Bash commands in controlled batches on that PC (build 26200.8655), from hidden, minimised and foreground consoles, about half of them with the workaround off, and none of the batches left tokens behind. Microsoft places the bug in Windows' foreground-permission logic, and it clearly needs more than "a command ran". So a quick test that shows nothing does not prove you are safe. Leave PoolWatch open over an afternoon of real work and watch the Toke row instead.

The four views

The Pool tags view

Pool tags. Every tag Windows reports (a few thousand), largest first or fastest-growing first, with the number of objects and the change per minute. A tag that keeps a positive change per minute while its object count only rises is your leak. Search the web for the four letters, or look them up in pooltag.txt from the Debugging Tools, to find the driver behind it.

The Schedule view

Schedule. Move out of RAM by itself, every 5 minutes to every 24 hours or daily at a set time. A run is skipped while little paged pool is in RAM, and while a game, a video or a presentation fills the screen, because the move makes running programs stutter for a moment. Windows asks for permission once, when you switch this on; after that neither scheduled runs nor the button raise a prompt. Every run and every skip is listed.

The Settings view

Settings. The token-leak workaround and Keep it on, start with Windows, how often readings are taken, keep on top, and light or dark.

The tray icon carries a dot when tokens are leaking, shows the pool size when you hover, and has Open, Move out of RAM and Exit in its menu. Closing the window only hides it.

The token-leak workaround, and what it costs you

The workaround sets Windows' live foreground lock timeout to 0. With that, Windows skips the code path that leaks. The price: Windows' protection against programs stealing the keyboard focus is off while it is on, so any program can bring its window to the front by itself.

Two things make this awkward to do by hand, and they are what Keep it on is for:

  • Windows puts the value back at every sign-in, ignoring the registry. The setting has to be made again each time.
  • Windows refuses the change from a program in the background most of the time. PoolWatch makes the call at its own start, tries again from a freshly started copy of itself and keeps retrying. If the workaround is still off after 30 seconds it tells you with a notification, and opening its window then makes the change, because at that moment PoolWatch is the program in front. Every change it sees is written to workaround.log with the program that was in front at the time.

How that went on the PC above: at three real sign-ins the workaround was on at once, after 27 seconds, and after 15 minutes. In five tests where another program switched it off while PoolWatch sat in the tray, Windows refused every attempt for the 20 to 80 seconds each test lasted. So Keep it on is best effort, and the dot on the tray icon and the notification are there to tell you when it has not worked.

When your PC has the fix (KB5132057 or later), switch both off.

What it costs to run

Measured on the PC above with QueryProcessCycleTime, at the default window size and one reading a second:

What is showing Processor time per second
Monitor (six graphs) 2.0 to 2.3 ms, 0.2% of one core
Pool tags 1.0 ms
Schedule, Settings 0.2 to 0.4 ms
Hidden in the tray, or minimised 0.22 to 0.26 ms

Memory: 41 MB. A reading is four system calls; the graphs are drawn incrementally, so a new second costs one new column. The list of where memory goes, beside the graphs, adds one more call every 10 seconds while it shows: 3.5 to 6.7 ms each, under 0.7 ms per second.

The numbers are checked against the tools they replace. Every counter of every tag lies between two poolmon snapshots taken either side of a PoolWatch reading (3,564 tags), and the totals match Windows' performance counters within 0.05%.

What it changes on your PC

Where What When
HKCU\Software\PoolWatch settings and the list of recent runs always
HKCU\Software\Microsoft\Windows\CurrentVersion\Run, value PoolWatch the startup entry while Start with Windows is on
%LOCALAPPDATA%\PoolWatch\ workaround.log, helper.log, error.log, each kept small as things happen
The session's foreground lock timeout 0 instead of Windows' value. Nothing is written to Windows' own registry value while the workaround is on
Scheduled task PoolWatch move out of RAM runs with highest privileges, only while you are signed in only if you switch on Run automatically
%ProgramFiles%\PoolWatch\PoolWatch.exe a copy of the exe that the task runs, so that nothing running without administrator rights can swap the file the task starts only if you switch on Run automatically

PoolWatch never deletes anything by itself, so removing it is by hand: switch off Run automatically and Start with Windows, choose Exit from the tray icon, then delete the exe, the task in Task Scheduler, the PoolWatch folder under Program Files, the registry key and the folder under %LOCALAPPDATA%.

Limits

  • Nothing here frees leaked pool memory. Only a restart does. Use Restart: with Fast Startup on, Shut down keeps the kernel's memory and brings the leak back with it.
  • Non-paged pool cannot be moved out of RAM by any tool.
  • Moving memory out is not free. It goes to the pagefile and still counts against commit. Everything feels sluggish for a few seconds afterwards while programs pull back what they need.
  • The workaround turns off focus-stealing protection for as long as it is on.
  • One PC so far. The kernel structures it reads are the ones poolmon and RAMMap use, but it has only been run on Windows 11 25H2, x64.

How it works

What How
Pool sizes, commit, paged pool in RAM NtQuerySystemInformation, class 2 (SystemPerformanceInformation)
Per-tag allocations, frees and bytes class 22 (SystemPoolTagInformation): a few thousand entries in 0.3 ms
Standby, modified and free memory class 80 (SystemMemoryListInformation); memory in use leaves out modified memory, as Task Manager does
Where memory in use goes class 5 (SystemProcessInformation): private working sets, grouped by program, every 10 s while that list shows
Token leak rate growth of the outstanding Toke count against process starts (Proc allocations), with floors that ignore the bursts of normal start-up
Move out of RAM NtSetSystemInformation(80, MemoryEmptyWorkingSets), the call behind RAMMap's menu item
Runs without a prompt a Task Scheduler task registered through COM; the window asks it to run, and only ever passes one of two fixed words
The workaround SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0)

It does not run or depend on poolmon, RAMMap, performance counters, WMI or schtasks.exe. docs/SPEC.md is the full specification, including the structure offsets, the Task Scheduler behaviour that cost the most time, and what earlier builds got wrong.

Command line

Command What it does
PoolWatch.exe the window; if it is already running, brings that window up
PoolWatch.exe --tray starts in the notification area without a window
PoolWatch.exe --quit asks the running copy to exit
PoolWatch.exe --dump <file> writes one reading as text: totals and every pool tag
PoolWatch.exe --workaround on|off|status [file] changes or reads the workaround without a window
PoolWatch.exe --selftest <file> runs the 326 built-in checks and writes PASS or FAIL lines
PoolWatch.exe --shot <png> --demo [--view tags] [--theme light] draws a view to a picture without showing a window

--dump gives you poolmon-style data with no kit installed:

paged_pool_bytes=1295003648
nonpaged_pool_bytes=849797120
tokens_held=6490
tag=Toke|P|2379968|2373478|6490|11861184

Build it yourself

PoolWatch is C# on Windows Forms and builds with the C# compiler that is part of Windows: no Visual Studio, no .NET SDK, no packages.

git clone https://github.com/raihanworld/PoolWatch.git
cd PoolWatch
powershell -ExecutionPolicy Bypass -File build.ps1

build.ps1 asks a running copy to close, then writes PoolWatch.exe next to the script. build.ps1 -Dev builds PoolWatch.dev.exe instead and leaves a running copy alone.

Tests

  • PoolWatch.exe --selftest out.txt: 326 checks of the arithmetic, wording, layout at every window size and scale, and the scheduling logic.
  • tests\: PowerShell scripts that compare readings with poolmon and RAMMap, drive a test-mode window, measure the processor cost and exercise the scheduled task. Test mode uses its own settings key and task and only pretends to move memory, so your own settings stay as they are. tests\run_unattended.ps1 runs the ones that need nobody at the keyboard; each script's header says exactly what it touches.

Related

License

MIT. Not affiliated with Microsoft, AMD or Git for Windows.

About

Live monitor for Windows kernel pool memory: graphs, every pool tag by size or growth, move paged pool out of RAM by hand or on a schedule, and a switch for the Windows 11 token leak.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages