memsup
is part of the os_mon
application and all
configuration parameters are defined in the reference documentation for the os_mon
application.
memsup
is a process which supervises the memory usage for
the system and for individual processes, as follows:
system_memory_high_watermark
of
available system memory is allocated, as reported by the underlying operating
system, the alarm
system_memory_high_watermark
is set.
process_memory_high_watermark
of total system
memory, the alarm process_memory_high_watermark
is set.
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 memsup
process defines two alarms which are set by the
alarm_handler:set_alarm(Alarm)
function. Alarm
is defined
as:
{system_memory_high_watermark, []}
.system_memory_high_watermark
of the total available
memory.
{process_memory_high_watermark, Pid}
.process_memory_high_watermark
of the total available
memory.
These alarms are cleared automatically when the alarm cause is no longer valid.
There is also a interface to system dependent memory data,
get_system_memory_data/0
.
The output 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.
Time = integer()
A time interval, in milliseconds, which defines how often memory
is checked. The get_system_memory_data()
function is in no
way affected by this interval.
MemData = {TotalMemorySize, AllocatedBytes, {LargestPid,
PidAllocatedBytes}}
TotalMemorySize = integer()
AllocatedBytes = integer()
LargestPid = pid()
PidAllocatedBytes = integer()
Returns data about the memory in the
system. LargestPid
is the Pid of the largest Erlang
process in the system. PidAllocatedBytes
is the amount of
memory the LargestPid
has allocated.
get_system_memory_data() -> MemDataList
MemDataList = [TaggedValue ...]
TaggedValue = {Tag, Value}
Value = integer()
Tag = atom()
Gets system dependent memory data. The result is returned as a list containing tagged tuples, where the tag can be one of the following:
total_memory
free_memory
system_total_memory
total_memory
but not necessarily.
largest_free
number_of_free
As with get_memory_data()
, the values on Unix-like systems
indicate the amount of physical memory that is configured
and free.
The largest_free
and number_of_free
tags are currently only returned on a VxWorks system.
All memory sizes are presented as number of bytes.
get_procmem_high_watermark() -> integer()
Threshold as a percentage of the total available system memory. It specifies how much memory can be allocated by one Erlang process before an alarm is sent.
get_sysmem_high_watermark() -> integer()
Threshold as a percentage of the total available system memory. It specifies how much memory can be allocated by the system before an alarm is sent.
alarm_handler(3), os_mon(3)