Public Wiki editing is temporarily disabled to stop vandalism.
|
|
Table of Contents
DIRegEx WikiPublic Wiki editing is temporarily disabled to stop vandalism. Stack Overflow?Question: Apparently, specific patterns with specific subjects can drive DIRegEx into stack overflow errors. How can I avoid these? Answer: DIRegEx uses a recursive matching algorithm which can run out of stack space with extremely demanding patterns. The recursive algorithm was still chosen over an iterative implementation for performance reasons: Extensive testing revealed that DIRegEx runs multiple times faster with recursion than without. Even though stack overflows are a real problem, they happens so rarely with common regex patterns and subjects that most DIRegEx users will never notice. In case you ever do, these steps can help to avoid them. Obviously, all 3 options combined yield best results:
In Windows, the stack size is defined on a per-thread basis when the thread is created. This means that the calling thread's stack size applies to DIRegEx even if it is compiled into an external *.bpl or *.dll link library. It defaults to the application's stack size when called from the main thread. If the calling application's stack size is too small and you are unable to change its stack size because you are writing a plugin or extension for a larger application, you might want to run DIRegEx in a newly created thread. The Windows CreateThread() function's dwStackSize parameter allows to change the initially committed stack space, which you should choose according to your needs. Unfortunately, it is not possible to predict the required stack size in advance. It is highly dependent on the number of potential matches in the subject text. A pattern which works well with larger text can still fail with shorter ones if it encounters lots of failed matches which must be backtracked. TDIRegExSearchStream explainedThis page contains an interesting e-mail conversion about the internals of TDIRegExSearchStream and descendent classes (German). wiki/regex/index.txt · Last modified: 2009/10/28 19:28 (external edit)
|
| Copyright (c) 2000-2010 Ralf Junker – http://www.yunqa.de/delphi/ – Disclaimer – Haftungsausschluss – Impressum |