Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parsing goes out of memory
Message
From
09/11/2013 04:55:25
 
 
To
08/11/2013 17:59:04
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01587600
Message ID:
01587615
Views:
37
This message has been marked as a message which has helped to the initial question of the thread.
>The following methods, for specific operations, can be called millions of times:
>
>
>    ' Equivalent of VFP StrTran()
>    ' expC1 String
>    ' expC2 Search for specific character
>    ' expC3 Replace
>    Public Function StrTran(ByVal tcSearchIn As String, ByVal tcSearchFor As String, _
>     ByVal tcReplace As String) As String
>        Dim loStringBuilder As StringBuilder = New StringBuilder(tcSearchIn)
>        Return loStringBuilder.Replace(tcSearchFor, tcReplace).ToString()
>    End Function
>
>
>However, this is usually not the case. So, a hit will require about 20 SQL Server requests, which in turn call this method for some adjustments, combined with some other application code logistic that might require it. The problem is if this is called millions of times in a short period, such as within 30 seconds or a minute, I have this "Out of memory" issue. Is there something I am missing here? I am returning a string to the caller. This is fairly simple. It is just two lines.

As Rob points out there's no advantage, memory wise, in using StringBuilder() here - you are still creating a new string with each call. If you are doing multiple replaces with repeated calls for the same initial string then this shows one approach (and an interesting speed comparison):

http://stackoverflow.com/questions/6524528/string-replace-vs-stringbuilder-replace

If worst comes to worst you can use MemoryFailPoint ( http://msdn.microsoft.com/en-us/library/system.runtime.memoryfailpoint(v=vs.110).aspx ) to avoid OOM exceptions.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform