## Copyright (C) 2019 Philip Nienhuis ## ## This program is free software: you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see ## . ## -*- texinfo -*- ## @deftypefn {} {@var{ram_usage} =} wmemory (@var{process}) ## Get memory usage of @var{process} in Kbytes. ## ## If @var{process} is omitted RAM usage of Octave is shown. If M processes ## with matching names an Mx1 array of double values is returned. ## @var{process} is case-insensitive. In case of errors or if @var{process} ## isn't active NaN is returned. ## ## @seealso{} ## @end deftypefn ## Author: Philip Nienhuis ## Created: 2019-01-17 function ram = wmemory (process = "octave") if (! ispc) error ("wmemory.m: this functions works only on Windows systems"); endif ram = NaN; if (! ischar (process)) error ("wmemory.m: process name expected."); elseif (isempty (process)) return end [~, d] = system ("tasklist"); d = strsplit (d, "\n")'; try d = d(strncmpi (d, process, length (process))); ram = cellfun (@(x) sscanf (strrep (x(65:end), " ", ""), "%d"), d, "uni", 1); end_try_catch endfunction