none
'SQlite EXCEPTION: out of memory' after a random amount of records have been saved. RRS feed

  • Question

  • I have this code that saves to an SQLite database.

    Unfortunately it seems to be throwing ‘out of memory’ errors once a few records are saved. Even though the scanner still has memory left. It also isn't the same amount of records each time, and can vary from a few hundred to tens!

        Public Sub InsertToLocalStorage(ByVal inputLocation As String, ByVal inputItem As String)
            Try 'Add a record to the local storage table
                If SlConn.State <> ConnectionState.Open Then SlConn.Open()
                Dim SlComm As SQLiteCommand = New SQLiteCommand(SlConn)
                strSQL = "INSERT INTO LocalScans(LocationLabel,ItemLabel,ScanDate) "
                strSQL += "VALUES ('" & inputLocation & "', '" & inputItem & "', '" & Date.Now.ToString("MM/dd/yy HH:mm:ss") & "')"
                SlComm.CommandText = strSQL
                SlComm.ExecuteNonQuery()
                SlComm.Dispose()
                If SlConn.State = ConnectionState.Open Then SlConn.Close()
                SlConn.Dispose()
                
                _logger.Debug("SQL-" + strSQL)
            Catch ex As Exception
                Dim errStr As String = "Unexpected error saving to localScan db"
                _logger.ErrorException(errStr, ex)
                MsgBox("Unexpected Error Saving to Local Database:" + Environment.NewLine + ex.ToString, MsgBoxStyle.Exclamation, "Database Error:")
            End Try
        End Sub

    SlConn and strSQL are both defined as private variables out with this process:

        Private SlConn As SQLiteConnection = New SQLiteConnection("Data Source=" & appPath & "\Data\LocalScan.s3db")
        Private strSQL As String = String.Empty

    I'm not sure why this would suddenly come up with a memory error after a random amount of records have been saved.

    Could this be caused by memory leakage?



    Friday, November 28, 2014 4:33 PM

All replies

  • Hi Garry,

    Thanks for posting in MSDN forum.

    Form your decritption, please to check It is able to match of your source rows and the your database table rows. As far as I know, out memory exception may  caused when you store your data on the memory instead of the database table. You may need to confirm the  InsertToLocalStorage function Being properly used.

    Shu Hu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, December 3, 2014 9:29 AM