System.OutOfMemoryException was thrown. at Go60505(RegexRunner ) at System.Text.RegularExpressions.C

Posted by Deanvr on Stack Overflow See other posts from Stack Overflow or by Deanvr
Published on 2010-04-12T16:07:09Z Indexed on 2010/04/12 16:52 UTC
Read the original article Hit count: 336

Filed under:
|
|

Hi All,

I am a c# dev working on some code for a website in vb.net. We use a lot of caching on a 32bit iss 6 win 2003 box and in some cases run into OutOfMemoryException exceptions. This is the code I trace it back to and would like to know if anyone else has has this...

Public Sub CreateQueryStringNodes()
    'Check for nonstandard characters'
    Dim key As String
    Dim keyReplaceSpaces As String
    Dim r As New Regex("^[-a-zA-Z0-9_]+$", RegexOptions.Compiled)

    For Each key In HttpContext.Current.Request.Form
        If Not IsNothing(key) Then
            keyReplaceSpaces = key.Replace(" ", "_")
            If r.IsMatch(keyReplaceSpaces) Then
                CreateNode(keyReplaceSpaces, HttpContext.Current.Request(key))
            End If
        End If
    Next

    For Each key In HttpContext.Current.Request.QueryString
        If Not IsNothing(key) Then
            keyReplaceSpaces = key.Replace(" ", "_")

            If r.IsMatch(keyReplaceSpaces) Then
                CreateNode(keyReplaceSpaces, HttpContext.Current.Request(key).Replace("--", "-"))
            End If
        End If
    Next
End Sub

.NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

error:

Exception of type 'System.OutOfMemoryException' was thrown. at Go60505(RegexRunner ) at System.Text.RegularExpressions.CompiledRegexRunner.Go() at System.Text.RegularExpressions.RegexRunner.Scan(Regex regex, String text, Int32 textbeg, Int32 textend, Int32 textstart, Int32 prevlen, Boolean quick) at System.Text.RegularExpressions.Regex.Run(Boolean quick, Int32 prevlen, String input, Int32 beginning, Int32 length, Int32 startat) at System.Text.RegularExpressions.Regex.IsMatch(String input) at Xcite.Core.XML.Write.CreateQueryStringNodes() at Xcite.Core.XML.Write..ctor(String IncludeSessionAndPostedData) at mysite._Default.Page_Load(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at

thanks

© Stack Overflow or respective owner

Related posts about .NET

Related posts about vb.net