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
gwmi backend: Format-Table drops the WorkingSetSize column without a console (width 80), memory becomes NaN #196
Thanks for 4.1.0 - detecting WMIC.exe (#195) fixed memory reporting for us under pm2 on Windows Server. Reporting a remaining problem in the gwmi backend, which is still used where WMIC is absent (WMIC is an optional, deprecated feature on Windows 11 24H2+ / Server 2025) or with useGwmi: true.
What happens
lib/gwmi.js runs gwmi win32_process -Filter '...' | select CreationDate,KernelModeTime,ParentProcessId,ProcessId,UserModeTime,WorkingSetSize | format-table and splits each row on whitespace. Format-Table lays out to the host buffer width. When the calling process has no console (a Windows service, session 0, a process created via WMI), PowerShell uses a width of 80. A row needs ~95 characters, so Format-Table silently drops the last column:
line[5] is undefined, so memory is NaN (null after JSON). The row check line.length === 1 lets the 5-column row through.
Reproduce
On Windows Server 2016 with pidusage 4.1.0, start this from a process without a console (for example Invoke-CimMethod -ClassName Win32_Process -MethodName Create, or from a Windows service):
From an interactive terminal (width 120) both calls return bytes.
Suggestion
Make the output independent of the console width, for example | ConvertTo-Csv -NoTypeInformation (or | Format-Table -AutoSize | Out-String -Width 4096) and parse that. Checking line.length !== 6 as wmic.js does would at least report an error instead of NaN.
Activity