1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
|
.TH memsup 3 "os_mon 2.1.6" "Ericsson AB" "ERLANG MODULE DEFINITION"
.SH MODULE
memsup \- A Memory Supervisor Process
.SH DESCRIPTION
.LP
\fImemsup\fR 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(6)\&. Available for Unix, Windows and VxWorks\&.
.LP
Periodically performs a memory check:
.RS 2
.TP 2
*
If more than a certain amount of available system memory is allocated, as reported by the underlying operating system, the alarm \fI{system_memory_high_watermark, []}\fR is set\&.
.TP 2
*
If any Erlang process \fIPid\fR in the system has allocated more than a certain amount of total system memory, the alarm \fI{process_memory_high_watermark, Pid}\fR is set\&.
.RE
.LP
Alarms are reported to the SASL alarm handler, see alarm_handler(3)\&. To set an alarm, \fIalarm_handler:set_alarm(Alarm)\fR is called where \fIAlarm\fR is either of the alarms specified above\&.
.LP
The alarms are cleared automatically when the alarm cause is no longer valid\&.
.LP
The function get_memory_data() can be used to retrieve the result of the latest periodic memory check\&.
.LP
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\&.
.LP
A call to \fIget_system_memory_data/0\fR is more costly than a call to \fIget_memory_data/0\fR as data is collected synchronously when this function is called\&.
.LP
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\&.
.SH CONFIGURATION
.LP
The following configuration parameters can be used to change the default values for time intervals and thresholds:
.RS 2
.TP 4
.B
\fImemory_check_interval = int()>0\fR:
The time interval, in minutes, for the periodic memory check\&. The default is one minute\&.
.TP 4
.B
\fIsystem_memory_high_watermark = float()\fR:
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%)\&.
.TP 4
.B
\fIprocess_memory_high_watermark = float()\fR:
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%)\&.
.TP 4
.B
\fImemsup_helper_timeout = int()>0\fR:
A timeout, in seconds, for how long the \fImemsup\fR process should wait for a result from a memory check\&. If the timeout expires, a warning message \fI"OS_MON (memsup) timeout"\fR is issued via \fIerror_loger\fR and any pending, synchrous 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\&.
.RS 4
.LP
.LP
The default is 30 seconds\&.
.RE
.TP 4
.B
\fImemsup_system_only = bool()\fR:
Specifies whether the \fImemsup\fR process should only check system memory usage (\fItrue\fR) or not\&. The default is \fIfalse\fR, meaning that information regarding both system memory usage and Erlang process memory usage is collected\&.
.RS 4
.LP
.LP
It is recommended to set this parameter to \fIfalse\fR on systems with many concurrent processes, as each process memory check makes a traversal of the entire list of processes\&.
.RE
.RE
.LP
See config(4) for information about how to change the value of configuration parameters\&.
.SH EXPORTS
.LP
.B
get_memory_data() -> {Total,Allocated,Worst}
.br
.RS
.TP
Types
Total = Allocated = int()
.br
Worst = {Pid, PidAllocated} | undefined
.br
Pid = pid()
.br
PidAllocated = int()
.br
.RE
.RS
.LP
Returns the result of the latest memory check, where \fITotal\fR is the total memory size and \fIAllocated\fR the allocated memory size, in bytes\&.
.LP
\fIWorst\fR is the pid and number of allocated bytes of the largest Erlang process on the node\&. If \fImemsup\fR should not collect process data, that is if the configuration parameter \fImemsup_system_only\fR was set to \fItrue\fR, \fIWorst\fR is \fIundefined\fR\&.
.LP
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\&.
.LP
Returns \fI{0, 0, {pid(), 0}}\fR or \fI{0, 0, undefined}\fR if \fImemsup\fR is not available, or if all memory checks so far have timed out\&.
.RE
.LP
.B
get_system_memory_data() -> MemDataList
.br
.RS
.TP
Types
MemDataList = [{Tag, Size}]
.br
Tag = atom()
.br
Size = int()
.br
.RE
.RS
.LP
Invokes a memory check and returns the resulting, system dependent, data as a list of tagged tuples, where \fITag\fR can be one of the following:
.RS 2
.TP 4
.B
\fItotal_memory\fR:
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\&.
.TP 4
.B
\fIfree_memory\fR:
The amount of free memory available to the Erlang emulator for allocation\&.
.TP 4
.B
\fIsystem_total_memory\fR:
The amount of memory available to the whole operating system\&. This may well be equal to \fItotal_memory\fR but not necessarily\&.
.TP 4
.B
\fIlargest_free\fR:
The size of the largest contiguous free memory block available to the Erlang emulator\&.
.TP 4
.B
\fInumber_of_free\fR:
The number of free blocks available to the Erlang runtime system\&. This gives a fair indication of how fragmented the memory is\&.
.RE
.LP
All memory sizes are presented as number of \fIbytes\fR\&.
.LP
The \fIlargest_free\fR and \fInumber_of_free\fR tags are currently only returned on a VxWorks system\&.
.LP
Returns the empty list [] if \fImemsup\fR is not available, or if the memory check times out\&.
.RE
.LP
.B
get_check_interval() -> MS
.br
.RS
.TP
Types
MS = int()
.br
.RE
.RS
.LP
Returns the time interval, in milliseconds, for the periodic memory check\&.
.RE
.LP
.B
set_check_interval(Minutes) -> ok
.br
.RS
.TP
Types
Minutes = int()>0
.br
.RE
.RS
.LP
Changes the time interval, given in minutes, for the periodic memory check\&.
.LP
The change will take effect after the next memory check and is non-persistant\&. That is, in case of a process restart, this value is forgotten and the default value will be used\&. See Configuration above\&.
.RE
.LP
.B
get_procmem_high_watermark() -> int()
.br
.RS
.LP
Returns the threshold, in percent, for process memory allocation\&.
.RE
.LP
.B
set_procmem_high_watermark(Float) -> ok
.br
.RS
.LP
Changes the threshold, given as a float, for process memory allocation\&.
.LP
The change will take effect during the next periodic memory check and is non-persistant\&. That is, in case of a process restart, this value is forgotten and the default value will be used\&. See Configuration above\&.
.RE
.LP
.B
get_sysmem_high_watermark() -> int()
.br
.RS
.LP
Returns the threshold, in percent, for system memory allocation\&.
.RE
.LP
.B
set_sysmem_high_watermark(Float) -> ok
.br
.RS
.LP
Changes the threshold, given as a float, for system memory allocation\&.
.LP
The change will take effect during the next periodic memory check and is non-persistant\&. That is, in case of a process restart, this value is forgotten and the default value will be used\&. See Configuration above\&.
.RE
.LP
.B
get_helper_timeout() -> Seconds
.br
.RS
.TP
Types
Seconds = int()
.br
.RE
.RS
.LP
Returns the timeout value, in seconds, for memory checks\&.
.RE
.LP
.B
set_helper_timeout(Seconds) -> ok
.br
.RS
.TP
Types
Seconds = int() (>= 1)
.br
.RE
.RS
.LP
Changes the timeout value, given in seconds, for memory checks\&.
.LP
The change will take effect for the next memory check and is non-persistant\&. That is, in the case of a process restart, this value is forgotten and the default value will be used\&. See Configuration above\&.
.RE
.SH SEE ALSO
.LP
alarm_handler(3), os_mon(3)
|