memsup(3erl) | Erlang Module Definition | memsup(3erl) |
memsup - A Memory Supervisor Process
memsup is a process which supervises the memory usage for the system and for individual processes. It is part of the OS_Mon application, see os_mon(7). Available for Unix, Windows and VxWorks.
Periodically performs a memory check:
Alarms are reported to the SASL alarm handler, see alarm_handler(3erl). To set an alarm, alarm_handler:set_alarm(Alarm) is called where Alarm is either of the alarms specified above.
The alarms are cleared automatically when the alarm cause is no longer valid.
The function get_memory_data() can be used to retrieve the result of the latest periodic memory check.
There is also a interface to system dependent memory data, get_system_memory_data(). 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.
A call to get_system_memory_data/0 is more costly than a call to get_memory_data/0 as data is collected synchronously when this function is called.
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.
The following configuration parameters can be used to change the default values for time intervals and thresholds:
The default is 30 seconds.
It is recommended to set this parameter to false on systems with many concurrent processes, as each process memory check makes a traversal of the entire list of processes.
See config(5) for information about how to change the value of configuration parameters.
get_memory_data() -> {Total,Allocated,Worst}
Types:
Returns the result of the latest memory check, where Total is the total memory size and Allocated the allocated memory size, in bytes.
Worst is the pid and number of allocated bytes of the largest Erlang process on the node. If memsup should not collect process data, that is if the configuration parameter memsup_system_only was set to true, Worst is undefined.
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.
Returns {0,0,{pid(),0}} or {0,0,undefined} if memsup is not available, or if all memory checks so far have timed out.
get_system_memory_data() -> MemDataList
Types:
Invokes a memory check and returns the resulting, system dependent, data as a list of tagged tuples, where Tag can be one of the following:
All memory sizes are presented as number of bytes.
The largest_free and number_of_free tags are currently only returned on a VxWorks system.
Returns the empty list [] if memsup is not available, or if the memory check times out.
get_os_wordsize() -> Wordsize
Types:
Returns the wordsize of the current running operating system.
get_check_interval() -> MS
Types:
Returns the time interval, in milliseconds, for the periodic memory check.
set_check_interval(Minutes) -> ok
Types:
Changes the time interval, given in minutes, for the periodic memory check.
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 Configuration above.
get_procmem_high_watermark() -> int()
Returns the threshold, in percent, for process memory allocation.
set_procmem_high_watermark(Float) -> ok
Changes the threshold, given as a float, for process memory allocation.
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 Configuration above.
get_sysmem_high_watermark() -> int()
Returns the threshold, in percent, for system memory allocation.
set_sysmem_high_watermark(Float) -> ok
Changes the threshold, given as a float, for system memory allocation.
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 Configuration above.
get_helper_timeout() -> Seconds
Types:
Returns the timeout value, in seconds, for memory checks.
set_helper_timeout(Seconds) -> ok
Types:
Changes the timeout value, given in seconds, for memory checks.
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 Configuration above.
os_mon 2.4.7 | Ericsson AB |