472,779 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 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 1395
"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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.