diff options
| author | Michael Klishin <michael@novemberain.com> | 2017-06-21 18:08:41 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-21 18:08:41 +0300 |
| commit | 6d20b774a3acc4e05728aa993e7bf78cef0d6b58 (patch) | |
| tree | 09075b826d7ffa647713e90f0fe5c144a887b1db | |
| parent | ed00c84c43705a95f5ee4941a58f49673a1d5979 (diff) | |
| parent | b5b529d2df4bd9ebb74a97e3dc616812d589d857 (diff) | |
| download | rabbitmq-server-git-6d20b774a3acc4e05728aa993e7bf78cef0d6b58.tar.gz | |
Merge pull request #1270 from rabbitmq/rabbitmq-server-1223-fix
Use wmic instead of tasklist to get Windows process memory
| -rw-r--r-- | src/vm_memory_monitor.erl | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/vm_memory_monitor.erl b/src/vm_memory_monitor.erl index f21dc91e0a..b07ff27f17 100644 --- a/src/vm_memory_monitor.erl +++ b/src/vm_memory_monitor.erl @@ -189,14 +189,12 @@ get_system_process_resident_memory({unix,openbsd}) -> get_system_process_resident_memory({win32,_OSname}) -> OsPid = os:getpid(), - Cmd = " tasklist /fi \"pid eq " ++ OsPid ++ "\" /fo LIST 2>&1 ", + Cmd = "wmic process where processid=" ++ OsPid ++ " get WorkingSetSize /value 2>&1", CmdOutput = os:cmd(Cmd), - %% Memory usage is displayed in kilobytes - %% with comma-separated thousands - case re:run(CmdOutput, "Mem Usage:\\s+([0-9,]+)\\s+K", [{capture, all_but_first, list}]) of + %% Memory usage is displayed in bytes + case re:run(CmdOutput, "WorkingSetSize=([0-9]+)", [{capture, all_but_first, binary}]) of {match, [Match]} -> - NoCommas = [ N || N <- Match, N =/= $, ], - {ok, list_to_integer(NoCommas) * 1024}; + {ok, binary_to_integer(Match)}; _ -> {error, {unexpected_output_from_command, Cmd, CmdOutput}} end; |
