You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Windows: process memory is null/0 when pm2 runs as a service since 7.0.1 - bump pidusage to 4.1.0 #6173
Since pm2 7.0.1 (pidusage 3.0.2 -> 4.0.1), on Windows pm2 ls shows memory as nullb for every process when the pm2 daemon runs as a Windows service (session 0, no console). pm2 jlist returns monit.memory: null, monitoring shows 0, and max_memory_restart never triggers. With pm2 6.x (pidusage 3.0.2) the same hosts reported memory correctly.
Root cause (pidusage 4.0.1)
lib/stats.js probes for wmic with spawn('wmic', function (err) { ... }). Passing a function as args makes Node throw ERR_INVALID_ARG_TYPE synchronously, so the catch branch always switches to the gwmi backend. wmic is never used, even where WMIC.exe exists.
The gwmi backend runs powershell gwmi win32_process ... | select ... | format-table and splits rows on whitespace. Without a console, PowerShell formats to a width of 80; a row is ~95 characters, so Format-Table drops the last column (WorkingSetSize) and parseInt(undefined) gives NaN (serialized as null).
From an interactive terminal (width 120) the same code works, which is why this mostly hits service installs.
Fix available upstream
pidusage 4.1.0 (2026-10-13, soyuka/pidusage#195) detects WMIC.exe once with fs.existsSync and uses wmic when it is present. index.js and the API are unchanged; pm2 only calls pidusage(pids, cb) in lib/God/ActionMethods.js.
We replaced node_modules/pm2/node_modules/pidusage with 4.1.0 on Windows Server 2016 hosts running pm2 7.0.4 as a service: memory is reported again, max_memory_restart works, and each poll is one wmic call instead of two powershell.exe launches (~0.3 s instead of ~0.9 s per poll in our measurement).
pm2 7.0.4 pins "pidusage": "4.0.1" exactly, so users cannot pick up the fix without patching the installed package. Could the dependency be bumped to ~4.1.0?
Environment
pm2 7.0.4, Node.js 24.22.0
Windows Server 2016, pm2 daemon started by a Windows service wrapper (LocalSystem / NetworkService)
Activity
#6173 bump pidusage 4.1.0
Unitech commentedon Nov 3, 2026
Fixed on pm2@7.1.1