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
|
[;1m-spec spawn_opt(Module, Function, Args, Options) ->[0m
[;1m Pid | {Pid, MonitorRef}[0m
[;1m when[0m
[;1m Module :: module(),[0m
[;1m Function :: atom(),[0m
[;1m Args :: [term()],[0m
[;1m Options :: [spawn_opt_option()],[0m
[;1m Pid :: pid(),[0m
[;1m MonitorRef :: reference().[0m
Types:
-type max_heap_size() ::
Size ::
non_neg_integer() |
#{size => non_neg_integer(),
kill => boolean(),
error_logger => boolean()}.
-type message_queue_data() :: off_heap | on_heap.
-type priority_level() :: low | normal | high | max.
-type spawn_opt_option() ::
link | monitor |
{monitor, MonitorOpts :: [monitor_option()]} |
{priority, Level :: priority_level()} |
{fullsweep_after, Number :: non_neg_integer()} |
{min_heap_size, Size :: non_neg_integer()} |
{min_bin_vheap_size, VSize :: non_neg_integer()} |
{max_heap_size, Size :: max_heap_size()} |
{message_queue_data, MQD :: message_queue_data()}.
Works as [;;4mspawn/3[0m, except that an extra option list is specified
when creating the process.
If option [;;4mmonitor[0m is specified, the newly created process is
monitored, and both the pid and reference for the monitor are
returned.
Options:
[;;4m[;;4mlink[0m[0m:
Sets a link to the parent process (like [;;4mspawn_link/3[0m does).
[;;4m[;;4mmonitor[0m[0m:
Monitors the new process (like [;;4mmonitor(process, Pid)[0m does).
A [;;4m{Pid, MonitorRef}[0m tuple will be returned instead of just a [;;4m[0m
[;;4mPid[0m.
[;;4m[;;4m{monitor, MonitorOpts}[0m[0m:
Monitors the new process with options (like [;;4mmonitor(process,[0m
[;;4mPid, MonitorOpts)[0m does). A [;;4m{Pid, MonitorRef}[0m tuple will be
returned instead of just a [;;4mPid[0m.
[;;4m[;;4m{priority, Level}[0m[0m:
Sets the priority of the new process. Equivalent to executing [;;4m[0m
[;;4mprocess_flag(priority, Level)[0m in the start function of the
new process, except that the priority is set before the
process is selected for execution for the first time. For more
information on priorities, see [;;4mprocess_flag(priority, Level)[0m.
[;;4m[;;4m{fullsweep_after, Number}[0m[0m:
Useful only for performance tuning. Do not use this option
unless you know that there is problem with execution times or
memory consumption, and ensure that the option improves
matters.
The Erlang runtime system uses a generational garbage
collection scheme, using an "old heap" for data that has
survived at least one garbage collection. When there is no
more room on the old heap, a fullsweep garbage collection is
done.
Option [;;4mfullsweep_after[0m makes it possible to specify the
maximum number of generational collections before forcing a
fullsweep, even if there is room on the old heap. Setting the
number to zero disables the general collection algorithm, that
is, all live data is copied at every garbage collection.
A few cases when it can be useful to change [;;4mfullsweep_after[0m:
• If binaries that are no longer used are to be thrown
away as soon as possible. (Set [;;4mNumber[0m to zero.)
• A process that mostly have short-lived data is
fullsweeped seldom or never, that is, the old heap
contains mostly garbage. To ensure a fullsweep
occasionally, set [;;4mNumber[0m to a suitable value, such as
10 or 20.
• In embedded systems with a limited amount of RAM and no
virtual memory, you might want to preserve memory by
setting [;;4mNumber[0m to zero. (The value can be set
globally, see [;;4merlang:system_flag/2[0m.)
[;;4m[;;4m{min_heap_size, Size}[0m[0m:
Useful only for performance tuning. Do not use this option
unless you know that there is problem with execution times or
memory consumption, and ensure that the option improves
matters.
Gives a minimum heap size, in words. Setting this value higher
than the system default can speed up some processes because
less garbage collection is done. However, setting a too high
value can waste memory and slow down the system because of
worse data locality. Therefore, use this option only for
fine-tuning an application and to measure the execution time
with various [;;4mSize[0m values.
[;;4m[;;4m{min_bin_vheap_size, VSize}[0m[0m:
Useful only for performance tuning. Do not use this option
unless you know that there is problem with execution times or
memory consumption, and ensure that the option improves
matters.
Gives a minimum binary virtual heap size, in words. Setting
this value higher than the system default can speed up some
processes because less garbage collection is done. However,
setting a too high value can waste memory. Therefore, use this
option only for fine-tuning an application and to measure the
execution time with various [;;4mVSize[0m values.
[;;4m[;;4m{max_heap_size, Size}[0m[0m:
Sets the [;;4mmax_heap_size[0m process flag. The default [;;4m[0m
[;;4mmax_heap_size[0m is determined by command-line argument [;;4m+hmax[0m
in [;;4merl(1)[0m. For more information, see the documentation of [;;4m[0m
[;;4mprocess_flag(max_heap_size, Size)[0m.
[;;4m[;;4m{message_queue_data, MQD}[0m[0m:
Sets the value of the [;;4mmessage_queue_data[0m process flag. [;;4mMQD[0m
can be either [;;4moff_heap[0m or [;;4mon_heap[0m. The default value of
the [;;4mmessage_queue_data[0m process flag is determined by the
command-line argument [;;4m+hmqd[0m in [;;4merl(1)[0m. For more
information, see the documentation of [;;4m[0m
[;;4mprocess_flag(message_queue_data, MQD)[0m.
|