473,387 Members | 1,897 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Regular expression problems

Hello al

I am not sure where to post this, so I hope this is correct.

We have written a Visual Studio AddIn that relies heavily on regular
expressions, which are often executed thousands of times. When running, it
works successfully for a while, but the Windows Page File Usage gradually
increases, and eventually the application freezes. We have traced the
problem to the regular expressions, but the problem does not apply equally
to all expressions. For example, the expression "^([\s]*)('|REM(
|\t|\v))([\s\S]*)$" does not cause any problems, whereas the expression
"^((("(("")|[^"])*")|([\s\S]*?))*)(('([\s\S]*))|$)$" causes a severe memory
leak. We always execute the expressions in 'interpreted' mode. Is there a
problem with certain expression constructs?

Thanks for any help/tips

Saira

Jul 21 '05 #1
1 1416
"Saira" <Saira@[NoSpam]BayonetVentures.com> wrote in
news:e5**************@TK2MSFTNGP09.phx.gbl...
Hello al

I am not sure where to post this, so I hope this is correct.

We have written a Visual Studio AddIn that relies heavily on regular
expressions, which are often executed thousands of times. When running, it
works successfully for a while, but the Windows Page File Usage gradually
increases, and eventually the application freezes. We have traced the
problem to the regular expressions, but the problem does not apply equally
to all expressions. For example, the expression "^([\s]*)('|REM(
|\t|\v))([\s\S]*)$" does not cause any problems, whereas the expression
"^((("(("")|[^"])*")|([\s\S]*?))*)(('([\s\S]*))|$)$" causes a severe
memory leak. We always execute the expressions in 'interpreted' mode. Is
there a problem with certain expression constructs?


I don't know where your memory leak is, but I can tell you for sure that
this expression is burning CPU power and memory. Try it out with pen&pencil
on a 5 or 10-character string! It's O(n^2), and it stores every single match
(remember that MS RegEx's also store intermediate captures!). Also, what's
[\s\S] good for? Wouldn't '.' do the same?

What are you doing with the Match object the RegEx returns? It should be
quite big. I've tried it in Expresso on a medium-sized code file, took about
40 MB of memory - But everything seemd to be properly freed up when the GC
kicked in.

Can you create a small sample that shows the behaviour you've described
(memory leak not cleaned up by the GC)?

Niki
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Andrew Gaskell | last post by:
Dear all I'm having problems generating a regular expression in .NET, having just started using regular expressions. I am trying to validate a user's full name. So far I have: * as the...
5
by: Bradley Plett | last post by:
I'm hopeless at regular expressions (I just don't use them often enough to gain/maintain knowledge), but I need one now and am looking for help. I need to parse through a document to find a URL,...
4
by: Neri | last post by:
Some document processing program I write has to deal with documents that have headers and footers that are unnecessary for the main processing part. Therefore, I'm using a regular expression to go...
18
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How...
1
by: Saira | last post by:
Hello al I am not sure where to post this, so I hope this is correct. We have written a Visual Studio AddIn that relies heavily on regular expressions, which are often executed...
2
by: Brian Kitt | last post by:
I have a process where I do some minimal reformating on a TAB delimited document to prepare for DTS load. This process has been running fine, but I recently made a change. I have a Full Text...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
1
by: Shawn B. | last post by:
Greetings, I'm using a custom WebBrowser control: http://www.codeproject.com/KB/miscctrl/csEXWB.aspx When I get the DocumentSource of a web page I browsed, and run a regular expression...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.