6536 |
ing long subject strings is to write repeated parenthesized subpatterns |
ing long subject strings is to write repeated parenthesized subpatterns |
6537 |
to match more than one character whenever possible. |
to match more than one character whenever possible. |
6538 |
|
|
6539 |
|
Compiling PCRE to use heap instead of stack |
6540 |
|
|
6541 |
In environments where stack memory is constrained, you might want to |
In environments where stack memory is constrained, you might want to |
6542 |
compile PCRE to use heap memory instead of stack for remembering back- |
compile PCRE to use heap memory instead of stack for remembering back- |
6543 |
up points. This makes it run a lot more slowly, however. Details of how |
up points. This makes it run a lot more slowly, however. Details of how |
6550 |
freed in reverse order, it may be possible to implement customized mem- |
freed in reverse order, it may be possible to implement customized mem- |
6551 |
ory handlers that are more efficient than the standard functions. |
ory handlers that are more efficient than the standard functions. |
6552 |
|
|
6553 |
|
Limiting PCRE's stack usage |
6554 |
|
|
6555 |
|
PCRE has an internal counter that can be used to limit the depth of |
6556 |
|
recursion, and thus cause pcre_exec() to give an error code before it |
6557 |
|
runs out of stack. By default, the limit is very large, and unlikely |
6558 |
|
ever to operate. It can be changed when PCRE is built, and it can also |
6559 |
|
be set when pcre_exec() is called. For details of these interfaces, see |
6560 |
|
the pcrebuild and pcreapi documentation. |
6561 |
|
|
6562 |
|
As a very rough rule of thumb, you should reckon on about 500 bytes per |
6563 |
|
recursion. Thus, if you want to limit your stack usage to 8Mb, you |
6564 |
|
should set the limit at 16000 recursions. A 64Mb stack, on the other |
6565 |
|
hand, can support around 128000 recursions. The pcretest test program |
6566 |
|
has a command line option (-S) that can be used to increase the size of |
6567 |
|
its stack. |
6568 |
|
|
6569 |
|
Changing stack size in Unix-like systems |
6570 |
|
|
6571 |
In Unix-like environments, there is not often a problem with the stack |
In Unix-like environments, there is not often a problem with the stack |
6572 |
unless very long strings are involved, though the default limit on |
unless very long strings are involved, though the default limit on |
6573 |
stack size varies from system to system. Values from 8Mb to 64Mb are |
stack size varies from system to system. Values from 8Mb to 64Mb are |
6588 |
attempts to increase the soft limit to 100Mb using setrlimit(). You |
attempts to increase the soft limit to 100Mb using setrlimit(). You |
6589 |
must do this before calling pcre_exec(). |
must do this before calling pcre_exec(). |
6590 |
|
|
6591 |
PCRE has an internal counter that can be used to limit the depth of |
Changing stack size in Mac OS X |
|
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. |
|
6592 |
|
|
6593 |
As a very rough rule of thumb, you should reckon on about 500 bytes per |
Using setrlimit(), as described above, should also work on Mac OS X. It |
6594 |
recursion. Thus, if you want to limit your stack usage to 8Mb, you |
is also possible to set a stack size when linking a program. There is a |
6595 |
should set the limit at 16000 recursions. A 64Mb stack, on the other |
discussion about stack sizes in Mac OS X at this web site: |
6596 |
hand, can support around 128000 recursions. The pcretest test program |
http://developer.apple.com/qa/qa2005/qa1419.html. |
|
has a command line option (-S) that can be used to increase the size of |
|
|
its stack. |
|
6597 |
|
|
6598 |
|
|
6599 |
AUTHOR |
AUTHOR |
6605 |
|
|
6606 |
REVISION |
REVISION |
6607 |
|
|
6608 |
Last updated: 05 June 2007 |
Last updated: 09 July 2008 |
6609 |
Copyright (c) 1997-2007 University of Cambridge. |
Copyright (c) 1997-2008 University of Cambridge. |
6610 |
------------------------------------------------------------------------------ |
------------------------------------------------------------------------------ |
6611 |
|
|
6612 |
|
|