Sophie

Sophie

distrib > Fedora > 17 > i386 > by-pkgid > 675c8c8167236dfcf8d66da674f931e8 > files > 1133

erlang-doc-R15B-03.3.fc17.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../../doc/otp_doc.css" type="text/css">
<title>Erlang -- memsup</title>
</head>
<body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container">
<script id="js" type="text/javascript" language="JavaScript" src="../../../../doc/js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../../../../doc/js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript">
            <!--
              function getWinHeight() {
                var myHeight = 0;
                if( typeof( window.innerHeight ) == 'number' ) {
                  //Non-IE
                  myHeight = window.innerHeight;
                } else if( document.documentElement && ( document.documentElement.clientWidth ||
                                                         document.documentElement.clientHeight ) ) {
                  //IE 6+ in 'standards compliant mode'
                  myHeight = document.documentElement.clientHeight;
                } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                  //IE 4 compatible
                  myHeight = document.body.clientHeight;
                }
                return myHeight;
              }

              function setscrollpos() {
                var objf=document.getElementById('loadscrollpos');
                 document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2;
              }

              function addEvent(obj, evType, fn){
                if (obj.addEventListener){
                obj.addEventListener(evType, fn, true);
                return true;
              } else if (obj.attachEvent){
                var r = obj.attachEvent("on"+evType, fn);
                return r;
              } else {
                return false;
              }
             }

             addEvent(window, 'load', setscrollpos);

             //--></script><div id="leftnav"><div class="innertube">
<img alt="Erlang logo" src="../../../../doc/erlang-logo.png"><br><small><a href="index.html">Reference Manual</a><br><a href="release_notes.html">Release Notes</a><br><a href="../pdf/os_mon-2.2.10.pdf">PDF</a><br><a href="../../../../doc/index.html">Top</a></small><p><strong>OS_Mon</strong><br><strong>Reference Manual</strong><br><small>Version 2.2.10</small></p>
<br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Table of Contents</strong></small></p>
<ul class="flipMenu">
<li title="os_mon (App)"><a href="os_mon_app.html">os_mon (App)
                </a></li>
<li id="no" title="cpu_sup " expanded="false">cpu_sup<ul>
<li><a href="cpu_sup.html">
                  Top of manual page
                </a></li>
<li title="nprocs-0"><a href="cpu_sup.html#nprocs-0">nprocs/0</a></li>
<li title="avg1-0"><a href="cpu_sup.html#avg1-0">avg1/0</a></li>
<li title="avg5-0"><a href="cpu_sup.html#avg5-0">avg5/0</a></li>
<li title="avg15-0"><a href="cpu_sup.html#avg15-0">avg15/0</a></li>
<li title="util-0"><a href="cpu_sup.html#util-0">util/0</a></li>
<li title="util-1"><a href="cpu_sup.html#util-1">util/1</a></li>
</ul>
</li>
<li id="no" title="disksup " expanded="false">disksup<ul>
<li><a href="disksup.html">
                  Top of manual page
                </a></li>
<li title="get_disk_data-0"><a href="disksup.html#get_disk_data-0">get_disk_data/0</a></li>
<li title="get_check_interval-0"><a href="disksup.html#get_check_interval-0">get_check_interval/0</a></li>
<li title="set_check_interval-1"><a href="disksup.html#set_check_interval-1">set_check_interval/1</a></li>
<li title="get_almost_full_threshold-0"><a href="disksup.html#get_almost_full_threshold-0">get_almost_full_threshold/0</a></li>
<li title="set_almost_full_threshold-1"><a href="disksup.html#set_almost_full_threshold-1">set_almost_full_threshold/1</a></li>
</ul>
</li>
<li id="loadscrollpos" title="memsup " expanded="true">memsup<ul>
<li><a href="memsup.html">
                  Top of manual page
                </a></li>
<li title="get_memory_data-0"><a href="memsup.html#get_memory_data-0">get_memory_data/0</a></li>
<li title="get_system_memory_data-0"><a href="memsup.html#get_system_memory_data-0">get_system_memory_data/0</a></li>
<li title="get_os_wordsize-0"><a href="memsup.html#get_os_wordsize-0">get_os_wordsize/0</a></li>
<li title="get_check_interval-0"><a href="memsup.html#get_check_interval-0">get_check_interval/0</a></li>
<li title="set_check_interval-1"><a href="memsup.html#set_check_interval-1">set_check_interval/1</a></li>
<li title="get_procmem_high_watermark-0"><a href="memsup.html#get_procmem_high_watermark-0">get_procmem_high_watermark/0</a></li>
<li title="set_procmem_high_watermark-1"><a href="memsup.html#set_procmem_high_watermark-1">set_procmem_high_watermark/1</a></li>
<li title="get_sysmem_high_watermark-0"><a href="memsup.html#get_sysmem_high_watermark-0">get_sysmem_high_watermark/0</a></li>
<li title="set_sysmem_high_watermark-1"><a href="memsup.html#set_sysmem_high_watermark-1">set_sysmem_high_watermark/1</a></li>
<li title="get_helper_timeout-0"><a href="memsup.html#get_helper_timeout-0">get_helper_timeout/0</a></li>
<li title="set_helper_timeout-1"><a href="memsup.html#set_helper_timeout-1">set_helper_timeout/1</a></li>
</ul>
</li>
<li id="no" title="os_mon_mib " expanded="false">os_mon_mib<ul>
<li><a href="os_mon_mib.html">
                  Top of manual page
                </a></li>
<li title="load-1"><a href="os_mon_mib.html#load-1">load/1</a></li>
<li title="unload-1"><a href="os_mon_mib.html#unload-1">unload/1</a></li>
</ul>
</li>
<li id="no" title="os_sup " expanded="false">os_sup<ul>
<li><a href="os_sup.html">
                  Top of manual page
                </a></li>
<li title="enable-0"><a href="os_sup.html#enable-0">enable/0</a></li>
<li title="enable-2"><a href="os_sup.html#enable-2">enable/2</a></li>
<li title="disable-0"><a href="os_sup.html#disable-0">disable/0</a></li>
<li title="disable-2"><a href="os_sup.html#disable-2">disable/2</a></li>
</ul>
</li>
<li id="no" title="nteventlog " expanded="false">nteventlog<ul>
<li><a href="nteventlog.html">
                  Top of manual page
                </a></li>
<li title="start-2"><a href="nteventlog.html#start-2">start/2</a></li>
<li title="start_link-2"><a href="nteventlog.html#start_link-2">start_link/2</a></li>
<li title="stop-0"><a href="nteventlog.html#stop-0">stop/0</a></li>
</ul>
</li>
</ul>
</div></div>
<div id="content">
<div class="innertube">
<!-- refpage --><center><h1>memsup</h1></center>
  
  <h3>MODULE</h3>
<div class="REFBODY">memsup</div>
  <h3>MODULE SUMMARY</h3>
<div class="REFBODY">A Memory Supervisor Process</div>
  <h3>DESCRIPTION</h3>
<div class="REFBODY"><p>
    <p><span class="code">memsup</span> is a process which supervises the memory usage for
      the system and for individual processes. It is part of the OS_Mon
      application, see <span class="bold_code"><a href="os_mon_app.html">os_mon(6)</a></span>.
      Available for Unix, Windows and VxWorks.</p>
    <p>Periodically performs a memory check:</p>
    <ul>
      <li>
        <p>If more than a certain amount of available system memory is
          allocated, as reported by the underlying operating system,
          the alarm <span class="code">{system_memory_high_watermark, []}</span> is set.</p>
      </li>
      <li>
        <p>If any Erlang process <span class="code">Pid</span> in the system has allocated
          more than a certain amount of total system memory, the alarm
          <span class="code">{process_memory_high_watermark, Pid}</span> is set.</p>
      </li>
    </ul>
    <p>Alarms are reported to the SASL alarm handler, see
      <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','sasl','alarm_handler.html');">alarm_handler(3)</a></span>.
      To set an alarm, <span class="code">alarm_handler:set_alarm(Alarm)</span> is called
      where <span class="code">Alarm</span> is either of the alarms specified above.</p>
    <p>The alarms are cleared automatically when the alarm cause is no
      longer valid.</p>
    <p>The function 
      <span class="bold_code"><a href="#get_memory_data-0">get_memory_data()</a></span>
      can be used to retrieve the result of the latest periodic memory
      check.</p>
    <p>There is also a interface to system dependent memory data,
      <span class="bold_code"><a href="#get_system_memory_data-0">get_system_memory_data()</a></span>.
      The result is highly dependent on the underlying operating
      system and the interface is targeted primarily for systems
      without virtual memory (e.g. VxWorks). The output on other
      systems is however still valid, although sparse.</p>
    <p>A call to <span class="code">get_system_memory_data/0</span> is more costly
      than a call to <span class="code">get_memory_data/0</span> as data is collected
      synchronously when this function is called.</p>
    <p>The total system memory reported under UNIX is the number of
      physical pages of memory times the page size, and the available
      memory is the number of available physical pages times the page
      size. This is a reasonable measure as swapping should be avoided
      anyway, but the task of defining total memory and available
      memory is difficult because of virtual memory and swapping.</p>
  </p></div>

  <h3><a name="id64458">Configuration</a></h3>
<div class="REFBODY">
    <a name="config"></a>
    
    <p>The following configuration parameters can be used to change
      the default values for time intervals and thresholds:</p>
    <dl>
      <dt><strong><span class="code">memory_check_interval = int()&gt;0</span></strong></dt>
      <dd>
        <p>The time interval, in minutes, for the periodic memory check.
          The default is one minute.</p>
      </dd>
      <dt><strong><span class="code">system_memory_high_watermark = float()</span></strong></dt>
      <dd>
        <p>The threshold, as percentage of system memory, for how much
          system memory can be allocated before the corresponding alarm
          is set. The default is 0.80 (80%).</p>
      </dd>
      <dt><strong><span class="code">process_memory_high_watermark = float()</span></strong></dt>
      <dd>
        <p>The threshold, as percentage of system memory, for how much
          system memory can be allocated by one Erlang process before
          the corresponding alarm is set. The default is 0.05 (5%).</p>
      </dd>
      <dt><strong><span class="code">memsup_helper_timeout = int()&gt;0</span></strong></dt>
      <dd>
        <p>A timeout, in seconds, for how long the <span class="code">memsup</span>
          process should wait for a result from a memory check. If
          the timeout expires, a warning message <span class="code">"OS_MON (memsup) timeout"</span> is issued via <span class="code">error_logger</span> and any
          pending, synchronous client calls will return a dummy value.
          Normally, this situation should not occur. There have been
          cases on Linux, however, where the pseudo file from which
          system data is read is temporarily unavailable when the system
          is heavily loaded.</p>
        <p>The default is 30 seconds. </p>
      </dd>
      <dt><strong><span class="code">memsup_system_only = bool()</span></strong></dt>
      <dd>
        <p>Specifies whether the <span class="code">memsup</span> process should only
          check system memory usage (<span class="code">true</span>) or not. The default is
          <span class="code">false</span>, meaning that information regarding both system
          memory usage and Erlang process memory usage is collected.</p>
        <p>It is recommended to set this parameter to <span class="code">false</span> on
          systems with many concurrent processes, as each process memory
          check makes a traversal of the entire list of processes.</p>
      </dd>
    </dl>
    <p>See <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','kernel','config.html');">config(4)</a></span> for
      information about how to change the value of configuration
      parameters.</p>
  </div>
  <h3>EXPORTS</h3>
    <p><a name="get_memory_data-0"><span class="bold_code">get_memory_data() -&gt; {Total,Allocated,Worst}</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">Total = Allocated = int()</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">Worst = {Pid, PidAllocated} | undefined</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code"> Pid = pid()</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code"> PidAllocated = int()</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Returns the result of the latest memory check, where
          <span class="code">Total</span> is the total memory size and <span class="code">Allocated</span>
          the allocated memory size, in bytes.</p>
        <p><span class="code">Worst</span> is the pid and number of allocated bytes of
          the largest Erlang process on the node. If <span class="code">memsup</span>
          should not collect process data, that is if the configuration
          parameter <span class="code">memsup_system_only</span> was set to <span class="code">true</span>,
          <span class="code">Worst</span> is <span class="code">undefined</span>.</p>
        <p>The function is normally asynchronous in the sense that it
          does not invoke a memory check, but returns the latest
          available value. The one exception if is the function is
          called before a first memory check is finished, in which case
          it does not return a value until the memory check is finished.</p>
        <p>Returns <span class="code">{0,0,{pid(),0}}</span> or <span class="code">{0,0,undefined}</span> if
          <span class="code">memsup</span> is not available, or if all memory checks so far
          have timed out.</p>
      </p></div>
    <p><a name="get_system_memory_data-0"><span class="bold_code">get_system_memory_data() -&gt; MemDataList</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">MemDataList = [{Tag, Size}]</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code"> Tag = atom()</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code"> Size = int()</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Invokes a memory check and returns the resulting, system
          dependent, data as a list of tagged tuples, where <span class="code">Tag</span>
          can be one of the following:</p>
        <dl>
          <dt><strong><span class="code">total_memory</span></strong></dt>
          <dd>The total amount of memory available to the Erlang emulator,
           allocated and free. May or may not be equal to the amount
           of memory configured in the system.</dd>
          <dt><strong><span class="code">free_memory</span></strong></dt>
          <dd>The amount of free memory available to the Erlang emulator
           for allocation.</dd>
          <dt><strong><span class="code">system_total_memory</span></strong></dt>
          <dd>The amount of memory available to the whole operating
           system. This may well be equal to <span class="code">total_memory</span> but
           not necessarily.</dd>
          <dt><strong><span class="code">largest_free</span></strong></dt>
          <dd>The size of the largest contiguous free memory block
           available to the Erlang emulator.</dd>
          <dt><strong><span class="code">number_of_free</span></strong></dt>
          <dd>The number of free blocks available to the Erlang runtime
           system. This gives a fair indication of how fragmented
           the memory is.</dd>
          <dt><strong><span class="code">buffered_memory</span></strong></dt>
          <dd>
                The amount of memory the system uses for temporary storing raw disk blocks.
          </dd>
          <dt><strong><span class="code">cached_memory</span></strong></dt>
          <dd>
                The amount of memory the system uses for cached files read from disk.
          </dd>
          <dt><strong><span class="code">total_swap</span></strong></dt>
          <dd>
                The amount of total amount of memory the system has available
                for disk swap.
          </dd>
          <dt><strong><span class="code">free_swap</span></strong></dt>
          <dd>
                The amount of memory the system has available for disk swap.
          </dd>

        </dl>
        <p>All memory sizes are presented as number of <strong>bytes</strong>.</p>
        <p>The <span class="code">largest_free</span> and <span class="code">number_of_free</span> tags are
          currently only returned on a VxWorks system.</p>
        <p>Returns the empty list [] if <span class="code">memsup</span> is not available,
          or if the memory check times out.</p>
	<div class="note">
<div class="label">Note</div>
<div class="content"><p><p>
	On linux the memory available to the emulator is <span class="code">cached_memory</span> and <span class="code">buffered_memory</span> in addition to 
	<span class="code">free_memory</span>.</p>
	</p></div>
</div>
      </p></div>
    <p><a name="get_os_wordsize-0"><span class="bold_code">get_os_wordsize() -&gt; Wordsize</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">Wordsize = 32 | 64 | unsupported_os</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Returns the wordsize of the current running operating system. </p>
      </p></div>
    <p><a name="get_check_interval-0"><span class="bold_code">get_check_interval() -&gt; MS</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">MS = int()</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Returns the time interval, in milliseconds, for the periodic
          memory check.</p>
      </p></div>
    <p><a name="set_check_interval-1"><span class="bold_code">set_check_interval(Minutes) -&gt; ok</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">Minutes = int()&gt;0</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Changes the time interval, given in minutes, for the periodic
          memory check.</p>
        <p>The change will take effect after the next memory check and is
          non-persistent. That is, in case of a process restart, this
          value is forgotten and the default value will be used. See
          <span class="bold_code"><a href="#config">Configuration</a></span> above.</p>
      </p></div>
    <p><a name="get_procmem_high_watermark-0"><span class="bold_code">get_procmem_high_watermark() -&gt; int()</span></a><br></p>
<div class="REFBODY"><p>
        <p>Returns the threshold, in percent, for process memory
          allocation.</p>
      </p></div>
    <p><a name="set_procmem_high_watermark-1"><span class="bold_code">set_procmem_high_watermark(Float) -&gt; ok</span></a><br></p>
<div class="REFBODY"><p>
        <p>Changes the threshold, given as a float, for process memory
          allocation.</p>
        <p>The change will take effect during the next periodic memory
          check and is non-persistent. That is, in case of a process
          restart, this value is forgotten and the default value will be
          used. See <span class="bold_code"><a href="#config">Configuration</a></span>
          above.</p>
      </p></div>
    <p><a name="get_sysmem_high_watermark-0"><span class="bold_code">get_sysmem_high_watermark() -&gt; int()</span></a><br></p>
<div class="REFBODY"><p>
        <p>Returns the threshold, in percent, for system memory
          allocation.</p>
      </p></div>
    <p><a name="set_sysmem_high_watermark-1"><span class="bold_code">set_sysmem_high_watermark(Float) -&gt; ok</span></a><br></p>
<div class="REFBODY"><p>
        <p>Changes the threshold, given as a float, for system memory
          allocation.</p>
        <p>The change will take effect during the next periodic memory
          check and is non-persistent. That is, in case of a process
          restart, this value is forgotten and the default value will be
          used. See <span class="bold_code"><a href="#config">Configuration</a></span>
          above.</p>
      </p></div>
    <p><a name="get_helper_timeout-0"><span class="bold_code">get_helper_timeout() -&gt; Seconds</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">Seconds = int()</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Returns the timeout value, in seconds, for memory checks.</p>
      </p></div>
    <p><a name="set_helper_timeout-1"><span class="bold_code">set_helper_timeout(Seconds) -&gt; ok</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">Seconds = int() (&gt;= 1)</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Changes the timeout value, given in seconds, for memory
          checks.</p>
        <p>The change will take effect for the next memory check and is
          non-persistent. That is, in the case of a process restart, this
          value is forgotten and the default value will be used. See
          <span class="bold_code"><a href="#config">Configuration</a></span> above.</p>
      </p></div>
  

  <h3><a name="id65194">See Also</a></h3>
<div class="REFBODY">
    
    <p><span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','sasl','alarm_handler.html');">alarm_handler(3)</a></span>,
      <span class="bold_code"><a href="os_mon_app.html">os_mon(3)</a></span></p>
  </div>
</div>
<div class="footer">
<hr>
<p>Copyright © 1997-2012 Ericsson AB. All Rights Reserved.</p>
</div>
</div>
</div></body>
</html>