Inserting large BLOB field (>500 MB) - System.OutOfMemoryException
------------------------------------------------------------------

                 Key: DNET-410
                 URL: http://tracker.firebirdsql.org/browse/DNET-410
             Project: .NET Data provider
          Issue Type: Bug
          Components: ADO.NET Provider
    Affects Versions: 2.7
         Environment: Windows 7 32&64 bit
            Reporter: Zsák Szabolcs
            Assignee: Jiri Cincura
            Priority: Critical


I tried to insert a new record to a table. The table had an integer and a Blob 
field.
The size of the blob value was more than 500 MB. 
An System.OutOfMemoryException exception is raised after ExecuteNonQuery.

This is the code:

            FbConnectionStringBuilder sb = new FbConnectionStringBuilder();
            sb.UserID = UserID;
            sb.Password = Password;
            sb.Database = Database;
            sb.DataSource = DataSource;
            sb.Port = Port;

            using (FbConnection conn = new FbConnection(sb.ConnectionString))
            {
                conn.Open();
                using (FbCommand comm = new FbCommand("INSERT INTO 
\"SomeTable\" (\"Id\",\"Image\") VALUES (@id,@blob)", conn))
                {
                    FbParameter p1 = comm.Parameters.Add("@blob", 
FbDbType.Binary);
                    p1.Value = System.IO.File.ReadAllBytes(BIGFILE);
                    p1.Direction = ParameterDirection.Input;

                    FbParameter p2 = comm.Parameters.Add("@id", 
FbDbType.Integer);
                    p2.Value = 1;
                    p2.Direction = ParameterDirection.Input;

                    comm.ExecuteNonQuery();
                }
                conn.Close();
            }

The memory consumption is big because of the InternalValue get-property of the 
FbParameter class. 
This get-property makes a copy from Blob value, and it's called many times. I 
think the objectcopy isn't necessary always!

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to