Skip to content

Commit 6d20b77

Browse files
Merge pull request #1270 from rabbitmq/rabbitmq-server-1223-fix
Use wmic instead of tasklist to get Windows process memory
2 parents ed00c84 + b5b529d commit 6d20b77

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/vm_memory_monitor.erl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,12 @@ get_system_process_resident_memory({unix,openbsd}) ->
189189

190190
get_system_process_resident_memory({win32,_OSname}) ->
191191
OsPid = os:getpid(),
192-
Cmd = " tasklist /fi \"pid eq " ++ OsPid ++ "\" /fo LIST 2>&1 ",
192+
Cmd = "wmic process where processid=" ++ OsPid ++ " get WorkingSetSize /value 2>&1",
193193
CmdOutput = os:cmd(Cmd),
194-
%% Memory usage is displayed in kilobytes
195-
%% with comma-separated thousands
196-
case re:run(CmdOutput, "Mem Usage:\\s+([0-9,]+)\\s+K", [{capture, all_but_first, list}]) of
194+
%% Memory usage is displayed in bytes
195+
case re:run(CmdOutput, "WorkingSetSize=([0-9]+)", [{capture, all_but_first, binary}]) of
197196
{match, [Match]} ->
198-
NoCommas = [ N || N <- Match, N =/= $, ],
199-
{ok, list_to_integer(NoCommas) * 1024};
197+
{ok, binary_to_integer(Match)};
200198
_ ->
201199
{error, {unexpected_output_from_command, Cmd, CmdOutput}}
202200
end;

0 commit comments

Comments
 (0)