Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OutOfMemory and StringBuilder
Message
De
12/01/2013 05:01:35
 
 
À
11/01/2013 17:10:50
Information générale
Forum:
ASP.NET
Catégorie:
Problèmes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01562245
Message ID:
01562293
Vues:
28
>I have four worker process answering the Web site. On one specific option a user did on the Web site, this has triggered a very long SQL command on SQL Server resulting in that process ID to take pretty much 100% of the memory available to it.
>
>Until we stopped that process, we ended up with several errors like this:
>
>"Exception of type 'System.OutOfMemoryException' was thrown."
>
>When looking at the trace, it was normal to see that the trace was pretty much different for each of them as, when there is no more memory available to process a transaction, an error can happen everywhere.
>
>However, what I do not understand, is one of them has this scenario. The Stack Trace ends up with at System.Text.StringBuilder.ToString() as the last item in it. This is from this method:
>
>
>        ' 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
>
>
>So, basically, because of a memory issue, the StringBuilder was not able to execute. However, as surprisingly as it gets, the insert into SQL Server to log this error worked.
>
>So, can anyone explain me why a simple command like that could trigger a 'System.OutOfMemoryException' when, at the same time, after it failed at that location, I was able to execute an insert into SQL Server?

Bear in mind that an OutOfMemoryException is thrown when a *request for memory* cannot be fulfilled. If you have 900Mb available and try to add a 1Gb string then you will get an exception. But that is not, in itself, fatal to the app - you still have 900Mb available and the process can continue to run. Whether you can safely handle an OOMException depends on the circumstances.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform