KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
memory.m
Go to the documentation of this file.
1 
2 
3 /* (Autoinserted by mtoc++)
4  * This source code has been filtered by the mtoc++ executable,
5  * which generates code that can be processed by the doxygen documentation tool.
6  *
7  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
8  * Except for the comments, the function bodies of your M-file functions are untouched.
9  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
10  * attached source files that are highly readable by humans.
11  *
12  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
13  * the correct locations in the source code browser.
14  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
15  */
16 
17 function varargout = memory() {
18 
19 if ispc
20  [varargout[1:nargout]] = builtin(" memory ");
21 else
22  userview = struct;
23  if isunix
24  v = -1;
25  cmd = " cat /proc/meminfo | grep MemFree ";
26  [s, msg] = system(cmd);
27  if s ~= 0
28  fprintf(2," Failed to run system command: %s: %s\n ", cmd, msg);
29  else
30  v = str2double(strtrim(msg(9:end-3)))*1024;
31  end
32  userview.MaxPossibleArrayBytes= v;
33  userview.MemAvailableAllArrays= v;
34 
35  v = -1;
36  cmd = " ps -e | grep MATLAB ";
37  [s, msg] = system(cmd);
38  msg = strtrim(msg);
39  if s ~= 0
40  fprintf(2," Failed to run system command '%s': %s\n ", cmd, msg);
41  else
42  pos = strfind(msg," ");
43  pid = str2double(msg(1:pos(1)-1));
44  /* pid2 = ppid; */
45  cmd = sprintf(" cat /proc/%d/status | grep VmSize ",pid);
46  [s, msg] = system(cmd);
47  if s ~= 0
48  fprintf(2," Failed to run system command '%s': %s\n ", cmd, msg);
49  else
50  v = str2double(strtrim(msg(8:end-3)))*1024;
51  end
52  end
53  userview.MemUsedMATLAB= v;
54 
55  /* Additional fields */
56  cmd = " cat /proc/meminfo | grep MemTotal ";
57  [s, msg] = system(cmd);
58  if s ~= 0
59  fprintf(2," Failed to run system command '%s': %s\n ", cmd, msg);
60  else
61  userview.TotalSystemMemory= str2double(strtrim(msg(10:end-3)))*1024;
62  end
63  elseif ismac
64  error(" not implemented for mac yet. ");
65  end
66  if nargout > 0
67  varargout[1] = userview;
68  else
69  disp(userview);
70  end
71 end
72 end
73 }
function varargout = memory()
memory: Imitates the memory function for all platforms.
Definition: memory.m:17
A variable number of output arguments.