OracleLob OutOfMemory exception

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
Siorg
Posts: 3
Joined: Wed 02 Dec 2009 08:54

OracleLob OutOfMemory exception

Post by Siorg » Thu 08 Sep 2011 11:34

Hi,

I want put to oracle large blob, when blob size goes over 300Mb i'm getting OutOfMemory exception.

Is there any workaround to put larger blobs?

Code:

FileStream str = new FileStream(ofDlg.FileName, FileMode.Open);
con.Open();
OracleLob myLob = new OracleLob(con, OracleDbType.Blob);
byte[] buffer = new byte[32768];
int read;
while ((read = str.Read(buffer, 0, buffer.Length)) > 0)
{
myLob.Write(buffer, 0, read); //OutOfMemory exception after ~300MB
}
str.Close();
OracleCommand myCommand = new OracleCommand(
"UPDATE BLOB_TABLE FDATA = :blobz WHERE AID = " + aid.Text, con);
OracleParameter myParam = myCommand.Parameters.Add("blobz", OracleDbType.Blob);
myParam.OracleValue = myLob;
try
{
myCommand.ExecuteNonQuery();
}
catch (OracleException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
}

Shalex
Devart Team
Posts: 8074
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 13 Sep 2011 15:59

We cannot reproduce the problem with dotConnect for Oracle v 6.50.214 using ~400MB file with our sample: http://www.devart.com/dotconnect/oracle ... leLob.html.
Try

Code: Select all

  FileStream fs = new FileStream(ofDlg.FileName, FileMode.Open, FileAccess.Read); 
  BinaryReader r = new BinaryReader(fs); 
  con.Open(); 
  OracleLob myLob = new OracleLob(con,OracleDbType.Blob); 
  int streamLength = (int)fs.Length; 
  myLob.Write(r.ReadBytes(streamLength), 0, streamLength);
instead of

Code: Select all

FileStream str = new FileStream(ofDlg.FileName, FileMode.Open);
con.Open();
OracleLob myLob = new OracleLob(con, OracleDbType.Blob);
byte[] buffer = new byte[32768];
int read;
while ((read = str.Read(buffer, 0, buffer.Length)) > 0)
{
myLob.Write(buffer, 0, read); //OutOfMemory exception after ~300MB
}
str.Close(); 

Post Reply