OutOfMemory Exception

OutOfMemory Exception

Postby dvck0 » Sat 21 Jan 2012 15:25

Hi,

I have problem with oracle provider by devart, I get exception OutOfMemory when I migrate DB with big LONG field and NCLOB field about 200 MB per one field.

I don't have real DB because it include secret data. I want build demo data for simulation this situation, but when I call savechanges I get outofmemory exception.

Please can you help me?

Thanks

PD

Code samples:

var sbb = new StringBuilder();
for (int i = 0; i < 15000000; i++)
{
sbb.Append("1234567890");
}

var text = sbb.ToString();

for (int j = 1; j < 50; j++)
{
var zvChar = new CHARAKTE()
{
CHARAK = text,
REG_CISLO = i,
ID = (i-1)*50 + j
};


Context.CHARAKTE.AddObject(zvChar);
Context.SaveChanges(); <------OutOfMemoryException
}

Exception:

at System.Text.Encoding.GetBytes(Char[] chars, Int32 index, Int32 count)
at System.Text.Encoding.GetBytes(String s)
at Devart.Data.Oracle.OracleParameter.a(Object A_0, Boolean A_1)
at Devart.Data.Oracle.OracleParameter.a(OracleDbType A_0, Object A_1, Object A_2, Byte[] A_3, Hashtable A_4, Int32 A_5, Int32 A_6, Int32 A_7, Int32 A_8, Int32 A_9, Boolean A_10, OracleConnection A_11, ParameterDirection A_12, String A_13, a6 A_14, Boolean& A_15)
at Devart.Data.Oracle.OracleParameter.a(ak& A_0, Boolean A_1, OracleConnection A_2, Byte[] A_3, Hashtable A_4, a6 A_5, Boolean& A_6, Int32 A_7)
at Devart.Data.Oracle.OracleCommand.a(ag A_0, Int32 A_1, OracleParameterCollection A_2, a6 A_3, Boolean& A_4)
at Devart.Data.Oracle.OracleCommand.InternalExecute(CommandBehavior behavior, IDisposable disposable, Int32 startRecord, Int32 maxRecords, Boolean nonQuery)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
at Devart.Data.Oracle.OracleCommand.ExecuteNonQuery()
at Devart.Common.Entity.o.ExecuteNonQuery()
at Devart.Data.Oracle.Entity.f.j()
at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues)
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)
at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
at System.Data.Objects.ObjectContext.SaveChanges()
dvck0
 
Posts: 2
Joined: Sat 21 Jan 2012 15:10

Postby Shalex » Mon 23 Jan 2012 14:43

There is a problem of multiple SaveChanges() call on the same instance of object context in your sample. All zvChar objects are cached in Context, and the size of the used memory goes up on every iteration. We recommend you to create a new context instance every time (will affect performance a little bit):
Code: Select all
for (int j = 1; j < 50; j++)
{
var zvChar = new CHARAKTE()
{
CHARAK = text,
REG_CISLO = i,
ID = (i-1)*50 + j
};

Context = new MyContextClass(); // this line is added
Context.CHARAKTE.AddObject(zvChar);
Context.SaveChanges();
}
Shalex
Devart Team
 
Posts: 7824
Joined: Thu 14 Aug 2008 12:44

Postby dvck0 » Mon 23 Jan 2012 16:00

Context include only one object :(
dvck0
 
Posts: 2
Joined: Sat 21 Jan 2012 15:10

Postby Shalex » Wed 25 Jan 2012 16:59

We are investigating the issue.
Shalex
Devart Team
 
Posts: 7824
Joined: Thu 14 Aug 2008 12:44

Postby Shalex » Thu 26 Jan 2012 12:21

We have answered you by e-mail.
Shalex
Devart Team
 
Posts: 7824
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle