Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Out of memory on loStringBuilder.ToString()
Message
From
06/06/2011 17:42:45
 
 
To
06/06/2011 16:49:49
General information
Forum:
ASP.NET
Category:
Troubleshooting
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01513090
Message ID:
01513248
Views:
35
Even, with only dumping string builder at that level, it fails on memory. Is there a way to negotiate directly with the string builder instead of using its .ToString() method?
        ' Create a file by passing an encoding
        ' expO1 String builder
        ' expC1 File
        ' expC2 Encoding
        ' expL1 If we log the error if the file cannot be deleted
        Public Function CreateFileEncoding(ByVal toStringBuilder As StringBuilder, ByVal tcFile As String, _
         ByVal tcEncoding As System.Text.Encoding, ByVal tlLogError As Boolean) As Boolean
            Dim llSuccess As Boolean = False
            Dim lnCounter As Integer = 0
            Dim lnDelay As Integer = 250
            Dim lnRetry As Integer = 8
            Dim loFileStream As FileStream
            Dim loStreamWriter As IO.StreamWriter

            For lnCounter = 1 To lnRetry

                Try
                    loFileStream = New FileStream(tcFile, FileMode.Create)
                    loStreamWriter = New StreamWriter(loFileStream, tcEncoding)
                    loStreamWriter.Write(toStringBuilder.ToString)
                    loStreamWriter.Close()
                    loFileStream.Close()
                    llSuccess = True
                    Exit For

                Catch loError As Exception

                    ' If we have not reached the maximum tries of 8, we retry
                    If lnCounter < 8 Then

                        ' Wait for a timeout before retrying
                        System.Threading.Thread.Sleep(lnDelay)

                        Continue For
                    End If

                    ' If we log the error
                    If tlLogError Then

                        ' Get the proper definition as per the current scope
                        If oProcess Is Nothing Then
                            oApp.ErrorSetup(loError)
                        Else
                            oProcess.ErrorSetup(loError)
                        End If

                    End If

                End Try

            Next

            Return llSuccess
        End Function
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform