| 123 |
documentation. |
documentation. |
| 124 |
.P |
.P |
| 125 |
As a very rough rule of thumb, you should reckon on about 500 bytes per |
As a very rough rule of thumb, you should reckon on about 500 bytes per |
| 126 |
recursion. Thus, if you want to limit your stack usage to 8Mb, you |
recursion. Thus, if you want to limit your stack usage to 8Mb, you should set |
| 127 |
should set the limit at 16000 recursions. A 64Mb stack, on the other hand, can |
the limit at 16000 recursions. A 64Mb stack, on the other hand, can support |
| 128 |
support around 128000 recursions. |
around 128000 recursions. |
| 129 |
.P |
.P |
| 130 |
In Unix-like environments, the \fBpcretest\fP test program has a command line |
In Unix-like environments, the \fBpcretest\fP test program has a command line |
| 131 |
option (\fB-S\fP) that can be used to increase the size of its stack. As long |
option (\fB-S\fP) that can be used to increase the size of its stack. As long |
| 135 |
limits. |
limits. |
| 136 |
. |
. |
| 137 |
. |
. |
| 138 |
|
.SS "Obtaining an estimate of stack usage" |
| 139 |
|
.rs |
| 140 |
|
.sp |
| 141 |
|
The actual amount of stack used per recursion can vary quite a lot, depending |
| 142 |
|
on the compiler that was used to build PCRE and the optimization or debugging |
| 143 |
|
options that were set for it. The rule of thumb value of 500 bytes mentioned |
| 144 |
|
above may be larger or smaller than what is actually needed. A better |
| 145 |
|
approximation can be obtained by running this command: |
| 146 |
|
.sp |
| 147 |
|
pcretest -m -C |
| 148 |
|
.sp |
| 149 |
|
The \fB-C\fP option causes \fBpcretest\fP to output information about the |
| 150 |
|
options with which PCRE was compiled. When \fB-m\fP is also given (before |
| 151 |
|
\fB-C\fP), information about stack use is given in a line like this: |
| 152 |
|
.sp |
| 153 |
|
Match recursion uses stack: approximate frame size = 640 bytes |
| 154 |
|
.sp |
| 155 |
|
The value is approximate because some recursions need a bit more (up to perhaps |
| 156 |
|
16 more bytes). |
| 157 |
|
.P |
| 158 |
|
If the above command is given when PCRE is compiled to use the heap instead of |
| 159 |
|
the stack for recursion, the value that is output is the size of each block |
| 160 |
|
that is obtained from the heap. |
| 161 |
|
. |
| 162 |
|
. |
| 163 |
.SS "Changing stack size in Unix-like systems" |
.SS "Changing stack size in Unix-like systems" |
| 164 |
.rs |
.rs |
| 165 |
.sp |
.sp |
| 210 |
.rs |
.rs |
| 211 |
.sp |
.sp |
| 212 |
.nf |
.nf |
| 213 |
Last updated: 10 January 2012 |
Last updated: 21 January 2012 |
| 214 |
Copyright (c) 1997-2012 University of Cambridge. |
Copyright (c) 1997-2012 University of Cambridge. |
| 215 |
.fi |
.fi |