Page 1 of 1

Stack overflow error

Posted: Tue Jan 29, 2002 2:27 pm
by scribe
When I search & replace with regular expressions, I sometimes get the error: "Recursion too deep; the stack overflowed." It usually happens when I work with large files with long lines (30,000+ bytes per line).

Does Textpad have a limit to how large files can be, or is this a problem with Windows/my PC's memory?

Re: Stack overflow error

Posted: Tue Jan 29, 2002 3:55 pm
by Stephan
We probably need an example of the RegEx you use.
You can easily make a RegEx consume _huge_ amounts of memory, if the RegEx is statet, er, less than optimal.

With complex regular expression you can get into very deep recurions levels when the RegEx 'backtracks' a lot. This is the case if there are stars *, pluses + and their friends included.
Then every time a Regex part following such a special character forces this special cahr to give up a char (one at a time) and tries again to mach. (Yes, it's relatively complex...)
Now imagine there are some '*'s (or the like) nested...

Did That help? I really hope so.

Re: Stack overflow error

Posted: Tue Jan 29, 2002 5:07 pm
by scribe
Thanks, that sort of helps... I'm using regular expressions to swap things around, e.g.:
^([^<]+)(<marker>)(.+)$
\3\2\1

If I had more RAM would the error pop up less often?

Thanks again