Sign In  Sign Up Live-Chat

System.OutOfMemoryException. Help!

Last post 01-04-2008, 8:06 PM by dean. 7 replies.
Sort Posts: Previous Next
  •  04-21-2005, 8:20 PM 18309

    System.OutOfMemoryException. Help!

    I get the following error when I try to bind a large dataset to an AdHoc object:

    Server Error in '/S056/powerplant' Application.

    --------------------------------------------------------------------------------

    Exception of type System.OutOfMemoryException was thrown.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.OutOfMemoryException: Exception of type System.OutOfMemoryException was thrown.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [OutOfMemoryException: Exception of type System.OutOfMemoryException was thrown.]

     

    --------------------------------------------------------------------------------

    Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET Version:1.1.4322.2300
    How do I fix this?

     
  •  04-25-2005, 1:24 AM 18454 in reply to 18309

    Re: System.OutOfMemoryException. Help!

    Dear S056,

     

    Thank you for your post.  The problem you are experiencing is derived from the size of the DataTable object.  Our team recently became aware of the situation and has been working on a solution to remedy it.  The primary problem we have faced is due to how the unique value feature will work with a disconnected set of data.  We believe we have now determined a workable solution.  Based on the priority of the problem we hope to have a resolution in place by the middle of this week.  As soon as the new release is ready I will be sure to post here.  Thank you again for your post and I hope to help have you problem resolved very soon.


    Danny Cooper
    Team Leader, Aspose Texas Team
    Contact Us
     
  •  05-02-2005, 6:37 AM 18798 in reply to 18454

    Re: System.OutOfMemoryException. Help!

    Dear S056,

     

    I wanted to write to give an updated status for this project.  Once again I have to apologize for the small delay.  Our staff is working diligently in order to release the new feature as soon as possible; however, we have faced more challenges than we initially thought.  I want to thank you for your patience and with the process.  As always, I will be sure to reply here once the new version is released.
    Danny Cooper
    Team Leader, Aspose Texas Team
    Contact Us
     
  •  05-13-2005, 1:34 AM 19533 in reply to 18798

    Re: System.OutOfMemoryException. Help!

    Dear S056,

     

    We have now completed and released the update to the Aspose.AdHoc component that allows it to support a disconnected data source.  This new change should help eliminate any memory issues you have been receiving on the server.  The following Blog post gives a brief overview of the new features: http://aspose.com/blogs/Danny.Cooper/archive/2005/05/13/806.aspx

     

    In order to utilize the new disconnected data source feature, you will be required to make code changes.  In order to help with the process I have had our team prepare a full code sample that shows how to utilize the new feature.  I have pasted it below for your convenience:

     

        ' Data Source Connect String

        Const ConnectString$ = "server=Nasa2;database=Northwind;User ID=sa;Password=test"

     

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

     

            ' Determine ReLoad

            If Not IsPostBack Then

     

                ' Set AdHoc component to use Disconnected Data Source

                ahMain.DisconnectedData = True

     

                ' Assign Data to AdHoc Control

                ahMain.DataSource = SQL2DataTable("SELECT TOP 1 * FROM [Invoices]")

                ahMain.DataBind()

     

                ' Assign Data Source Table / View Name

                ahMain.TableName = "Invoices"

     

            End If

     

        End Sub

     

        '* This routine handles the click of the AdHoc finish button

        Private Sub ahMain_Finish() Handles ahMain.Finish

     

            ' Variables

            Dim dtDB As DataTable

     

            ' Assign Value

            dtDB = ahMain.FilteredDataTable

     

            '** Do DataTable Work Here **'

     

            ' Free Memory

            dtDB.Dispose()

     

        End Sub

     

        '* This routine handles the request for unique values from the AdHoc component

        Private Sub ahMain_ValueRequest(ByVal Field As String, ByVal SQL As String) Handles ahMain.ValueRequest

     

            ' Load Unique Values

            ahMain.LoadExtValues(SQL2DataReader(SQL))

     

        End Sub

     

        '* This routine converts a SQL statement to a DataTable

        Public Shared Function SQL2DataTable(ByVal SQL$) As DataTable

     

            ' Variables

            Dim cDB As New SqlConnection(ConnectString)

     

            ' Append to DataAdapter

            Dim daDB As New SqlDataAdapter(SQL, cDB)

     

            ' Setup as SQL

            daDB.SelectCommand.CommandType = CommandType.Text

     

            ' Create and Fill the DataTable

            Dim dtDB As New DataTable()

            daDB.Fill(dtDB)

     

            ' Return the DataTable

            Return dtDB

     

        End Function

     

        '* This routine converts a SQL statement to a DataReader

        Public Shared Function SQL2DataReader(ByVal SQL$) As SqlDataReader

     

            ' Variables

            Dim cDB As New SqlConnection(ConnectString)

            Dim cmDB As New SqlCommand(SQL, cDB)

     

            ' Mark the Command as Text

            cmDB.CommandType = CommandType.Text

     

            ' Create and Fill the DataSet

            cDB.Open()

     

            ' Create Data Reader

            Dim drDB As SqlDataReader = cmDB.ExecuteReader(CommandBehavior.CloseConnection)

     

            ' Return Connection

            Return drDB

     

        End Function

     

     

    All you should need to do is download and install the newest version of the setup file from your personal Full version URL.  Please let me know if you encounter any difficulties and I will be more than glad to assist.

     

     


    Danny Cooper
    Team Leader, Aspose Texas Team
    Contact Us
     
  •  10-25-2005, 4:46 PM 34407 in reply to 19533

    Re: System.OutOfMemoryException. Help!

    I downloaded the latest version, and copied the code above, but I get this error on executing

    dtDB = ahMain.FilteredDataTable

    Filtered data objects can not be used when a disconnected data source is used. Please refer to the DisconnectedData property.

     
  •  10-25-2005, 7:40 PM 34430 in reply to 34407

    Re: System.OutOfMemoryException. Help!

    Dear andyoff,

    Thanks for your post,

    Please set the DisconnectedData to false, before try to get the filteredDataTable, as following

        Private Sub ahMain_Finish() Handles ahMain.Finish

            ' Variables
            Dim dvForGrid As DataView

           'SET the DisconnectedData to false
            Me.ahMain.DisconnectedData = False


            ' Assign Value
            dvForGrid = ahMain.FilteredDataView

            ' Store to Session
            Session("dvForGrid") = dvForGrid

            ' Show Output
            Response.Redirect("Output.aspx")

        End Sub

     


    Team Lead
    Aspose Guangzhou Team
    About Us

    Contact Us
     
  •  01-04-2008, 5:13 PM 107797 in reply to 19533

    Re: System.OutOfMemoryException. Help!

    How does this work using FilteredDataTable with DisconnectedData = true?  I get the message Filtered data objects can not be used when a disconnected data source is used.  Please refer to the DisconnectedData property.
     
  •  01-04-2008, 8:06 PM 107805 in reply to 107797

    Re: System.OutOfMemoryException. Help!

    Hi hinesgwn,

       Thanks for your post!

       If DisconnectedData was true, the Filtered Data objects will be null and can not be used. In usually, we will use the FilteredSQL to query the database and get the result, the codes may look like:

          //...

       SqlDataReader sqlReader = SQL2DataReader(this.AdHoc1.FilteredSQL);

          //...

       Set the DisconnectedData to be true will allow you to work with large number of rows in the data base and prevent the memory from running out.

       If you still want to use the Filtered Data objects, you can reset the DisconnectedData to false before refering these objects as the example in iret's post:

        Private Sub ahMain_Finish() Handles ahMain.Finish

            ' Variables
            Dim myTable As DataTable

           'SET the DisconnectedData to false
            Me.ahMain.DisconnectedData = False


            ' Assign Value
            myTable = ahMain.FilteredDataTable

            ' Store to Session
            Session("myTable ") = myTable

            ' Show Output
            Response.Redirect("Output.aspx")

        End Sub

       Thanks


    Dean Deng
    Lead Developer
    Aspose Guangzhou Team
    About Us
    Contact Us
     
View as RSS news feed in XML