Skip to content

fix(proxy): use working-set memory for the Windows solver cap - #93

Merged
ZepiGit merged 2 commits into
mainfrom
fix/captcha-solver-memory
Nov 14, 2026
Merged

ZepiGit merged 2 commits into
mainfrom
fix/captcha-solver-memory

Conversation

@ZepiGit

@ZepiGit ZepiGit commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Problem

The captcha solver dies within seconds on Windows with the default 300 MB cap. Bun 1.4.2 commits memory it has not touched: crash reports show 66–96 MB of working set when the Windows Job Object reaches its 300 MB commit limit.

Changes

  • Measure the Windows solver's working set for solver.memoryCapMB. Its watcher checks every 100 ms and exits when the cap is reached.
  • Keep the Job Object as a hard commit ceiling at the configured cap plus 1024 MB, with readback verification and kill-on-close.
  • Recycle solver generations at 50% of the cap instead of 80%. Real solves retained memory and could peak about 120 MB above their starting footprint; the old threshold left only 60 MB of headroom at the default cap.
  • Add Windows regressions for untouched committed memory and the kernel ceiling. Update the current docs, matching README translations, config comments and MANIFEST notes.

The default remains 300 MB. No installed proxy or user configuration was changed.

Verification

  • Independent rerun of solver-cap.test.ts, solver-process.test.ts and solver-recycle.test.ts: 74 passed, 2 skipped, 0 failed.
  • Proxy typecheck: passed.
  • Full proxy suite reported by the implementation agent: 1817 passed, 5 skipped, 1 failed. The failure is in test-support/egress-guard.test.ts and also fails on untouched 6b1e520; this PR does not change it.
  • Linux/WSL2 solver tests reported by the implementation agent: 86 passed, 2 skipped, 3 timed out. Those same tests also time out on untouched 6b1e520 in that setup. Real solves under the cgroup cap: 5/5, with no cap exits.
  • The implementation agent measured real solves through the dispatcher on Windows: 0/4 before, 12/12 after, with no cap exits after the fix. A runaway touched-memory fixture was still stopped, and the Job Object refused allocations beyond its commit ceiling.

Limits and follow-up

  • The memory retained by each solve is not fixed; recycling contains it. More frequent cold starts cost about 3.3 seconds per solve on the measured Windows machine, compared with about 1 second warm.
  • Sampling can overshoot the resident-memory cap before the next check. The separate kernel commit ceiling remains higher than the resident target.
  • Windows may trim working sets under memory pressure. The commit ceiling still applies.
  • Historical release notes and memory-measurement records were left unchanged.

On Windows the solver's cap was a Job Object limit on commit charge, and the
footprint the solver reported was commit charge as well. A Bun process
commits far more than it uses. Measured with Bun 1.4.2 on 16 logical
processors, the solver's commit charge was about 100 MB before it had loaded
anything and 460 to 560 MB during its first solve, at 200 to 245 MB of
working set. Under the 300 MB default every solver process ran out of memory
within seconds of its start, and no solve finished.

The solver process now measures its working set on Windows and ends itself at
the cap, as it does where the operating system enforces nothing. The Job
Object stays as the bound the kernel enforces, 1024 MB of commit charge above
the cap, so a solver that commits memory without touching it is still
stopped. Linux and macOS measure as before.

The solver is now replaced at 50 % of the cap, down from 80 %. A real solve
peaks up to about 120 MB above the footprint it starts from and leaves about
40 MB behind, on Windows and on Linux. With 60 MB of room, two of four
generations on Windows ended at the cap on their third solve. At the default
cap a solver process now serves one solve on Windows and two on Linux, where
it served four.
The manifest lists the change to the vendored proxy. The READMEs, the
architecture notes and the glossary give the 50 % recycle threshold, and the
architecture notes say how the cap is enforced on Windows.
@ZepiGit
ZepiGit merged commit 409c3f6 into main Nov 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant