Mailfromd |
|
General-Purpose Mail Filter |
Sergey Poznyakoff |
Mailfromd Manual (split by node): | ? |
#pragma stacksize size #pragma stacksize size twice|incr #pragma stacksize size twice|incr max |
The stacksize
pragma sets the initial size of the run-time
stack and may also define the policy of its growing, in case it
becomes full. It takes one mandatory and two optional arguments. The
first argument gives the desired initial stack size, in words. It
defaults to 4096 words. You may wish to increase this number
if your configuration program uses recursive functions or does an
excessive amount of string manipulations. For example:
#pragma stacksize 7168 |
The size may end with a usual size suffix, i.e. one of:
Suffix | Meaning |
---|---|
k | Kiloword, i.e. 1024 words |
m | Megawords, i.e. 1048576 words |
g | Gigawords, |
t | Terawords (ouch!) |
File suffixes are case-insensitive:
#pragma stacksize 7m #pragma stacksize 7M |
When the MFL engine notices that there is no more stack space available, it attempts to expand the stack. If this attempt succeeds, the operation continues. Otherwise, a runtime error is reported and the execution of the filter stops.
Optional second argument to #pragma stacksize
defines growth
policy for the stack. A positive number in its place is taken for the
expansion chunk size. In this case, the stack will be grown in
blocks that contain integer number of expansion chunks. The following
example sets initial stack size to 10240, and expansion chunk size to
2048 words:
#pragma stacksize 10M 2K |
This incremental growth policy is the default. The default chunk size is 4096 words.
The word ‘twice’ in the second argument enables exponential stack growth policy:
#pragma stacksize 10240 twice |
In this case, when the run-time evaluator hits the stack size limit, it expands the stack to twice the size it had before. So, in the example above, the stack will be sequentially expanded to the following sizes: 20480, 40960, 81920, 163840.
Third argument to #pragma stacksize
defines maximum size of
the stack. If stack grows beyond this limit, the execution of the
script will be aborted.
If you are concerned about the execution time of your script, you
may wish to avoid stack reallocations. To help you find out the
optimal stack size, each time the stack is expanded,
mailfromd
issues a warning in its log file, which looks like
this:
warning: stack segment expanded, new size=8192 |
You can use these messages to adjust your stack size configuration settings.
Mailfromd Manual (split by node): | ? |
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.