OracleLob OutOfMemory exception

OracleLob OutOfMemory exception

Postby 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();
}
Siorg
 
Posts: 3
Joined: Wed 02 Dec 2009 08:54

Postby 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/docs/?Devart.Data.Oracle~Devart.Data.Oracle.OracleLob.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();
Shalex
Devart Team
 
Posts: 7703
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle