61 |
backtracking into the runs of non-"<" characters, but that is not related to |
backtracking into the runs of non-"<" characters, but that is not related to |
62 |
stack usage. |
stack usage. |
63 |
.P |
.P |
64 |
|
This example shows that one way of avoiding stack problems when matching long |
65 |
|
subject strings is to write repeated parenthesized subpatterns to match more |
66 |
|
than one character whenever possible. |
67 |
|
.P |
68 |
In environments where stack memory is constrained, you might want to compile |
In environments where stack memory is constrained, you might want to compile |
69 |
PCRE to use heap memory instead of stack for remembering back-up points. This |
PCRE to use heap memory instead of stack for remembering back-up points. This |
70 |
makes it run a lot more slowly, however. Details of how to do this are given in |
makes it run a lot more slowly, however. Details of how to do this are given in |
74 |
.\" |
.\" |
75 |
documentation. |
documentation. |
76 |
.P |
.P |
77 |
In Unix-like environments, there is not often a problem with the stack, though |
In Unix-like environments, there is not often a problem with the stack unless |
78 |
the default limit on stack size varies from system to system. Values from 8Mb |
very long strings are involved, though the default limit on stack size varies |
79 |
to 64Mb are common. You can find your default limit by running the command: |
from system to system. Values from 8Mb to 64Mb are common. You can find your |
80 |
|
default limit by running the command: |
81 |
.sp |
.sp |
82 |
ulimit -s |
ulimit -s |
83 |
.sp |
.sp |
84 |
The effect of running out of stack is often SIGSEGV, though sometimes an error |
Unfortunately, the effect of running out of stack is often SIGSEGV, though |
85 |
message is given. You can normally increase the limit on stack size by code |
sometimes a more explicit error message is given. You can normally increase the |
86 |
such as this: |
limit on stack size by code such as this: |
87 |
.sp |
.sp |
88 |
struct rlimit rlim; |
struct rlimit rlim; |
89 |
getrlimit(RLIMIT_STACK, &rlim); |
getrlimit(RLIMIT_STACK, &rlim); |
112 |
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 |
113 |
should set the limit at 16000 recursions. A 64Mb stack, on the other hand, can |
should set the limit at 16000 recursions. A 64Mb stack, on the other hand, can |
114 |
support around 128000 recursions. The \fBpcretest\fP test program has a command |
support around 128000 recursions. The \fBpcretest\fP test program has a command |
115 |
line option (\fB-S\fP) that can be used to increase its stack. |
line option (\fB-S\fP) that can be used to increase the size of its stack. |
116 |
.P |
.P |
117 |
.in 0 |
.in 0 |
118 |
Last updated: 29 June 2006 |
Last updated: 14 September 2006 |
119 |
.br |
.br |
120 |
Copyright (c) 1997-2006 University of Cambridge. |
Copyright (c) 1997-2006 University of Cambridge. |