--- code/trunk/doc/html/pcrestack.html 2008/07/08 14:18:28 357 +++ code/trunk/doc/html/pcrestack.html 2008/07/09 11:03:07 358 @@ -77,6 +77,9 @@ subject strings is to write repeated parenthesized subpatterns to match more than one character whenever possible.
+In environments where stack memory is constrained, you might want to compile PCRE to use heap memory instead of stack for remembering back-up points. This @@ -91,6 +94,30 @@ same, and are always freed in reverse order, it may be possible to implement customized memory handlers that are more efficient than the standard functions.
++PCRE has an internal counter that can be used to limit the depth of recursion, +and thus cause pcre_exec() to give an error code before it runs out of +stack. By default, the limit is very large, and unlikely ever to operate. It +can be changed when PCRE is built, and it can also be set when +pcre_exec() is called. For details of these interfaces, see the +pcrebuild +and +pcreapi +documentation. +
++As a very rough rule of thumb, you should reckon on about 500 bytes per +recursion. Thus, if you want to limit your stack usage to 8Mb, you +should set the limit at 16000 recursions. A 64Mb stack, on the other hand, can +support around 128000 recursions. The pcretest test program has a command +line option (-S) that can be used to increase the size of its stack. +
+In Unix-like environments, there is not often a problem with the stack unless very long strings are involved, though the default limit on stack size varies @@ -112,23 +139,14 @@ attempts to increase the soft limit to 100Mb using setrlimit(). You must do this before calling pcre_exec().
+-PCRE has an internal counter that can be used to limit the depth of recursion, -and thus cause pcre_exec() to give an error code before it runs out of -stack. By default, the limit is very large, and unlikely ever to operate. It -can be changed when PCRE is built, and it can also be set when -pcre_exec() is called. For details of these interfaces, see the -pcrebuild -and -pcreapi -documentation. -
--As a very rough rule of thumb, you should reckon on about 500 bytes per -recursion. Thus, if you want to limit your stack usage to 8Mb, you -should set the limit at 16000 recursions. A 64Mb stack, on the other hand, can -support around 128000 recursions. The pcretest test program has a command -line option (-S) that can be used to increase the size of its stack. +Using setrlimit(), as described above, should also work on Mac OS X. It +is also possible to set a stack size when linking a program. There is a +discussion about stack sizes in Mac OS X at this web site: +http://developer.apple.com/qa/qa2005/qa1419.html.
-Last updated: 05 June 2007
+Last updated: 09 July 2008
-Copyright © 1997-2007 University of Cambridge.
+Copyright © 1997-2008 University of Cambridge.
Return to the PCRE index page.