SQL Server CE allocates too much memory with blob and sql prepare

Description

When using prepare_sql with SQL Server CE 32 bits, OutOfMemoryException occurs on queries binding blob parameters (text or binary).

Example stack trace:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 System.OutOfMemoryException : Insufficient memory to continue the execution of the program. at System.Runtime.InteropServices.Marshal.AllocCoTaskMem(Int32 cb) at System.Data.SqlServerCe.Accessor.AllocData() at System.Data.SqlServerCe.SqlCeCommand.CreateAccessorFromParameterList() at System.Data.SqlServerCe.SqlCeCommand.CreateDataBindings() at System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan() at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options) at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery() at NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(DbCommand cmd) at NHibernate.AdoNet.NonBatchingBatcher.AddToBatch(IExpectation expectation) at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session) at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Object obj, ISessionImplementor session) at NHibernate.Action.EntityInsertAction.Execute() at NHibernate.Engine.ActionQueue.Execute(IExecutable executable) at NHibernate.Engine.ActionQueue.ExecuteActions(IList list) at NHibernate.Engine.ActionQueue.ExecuteActions() at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event) at NHibernate.Impl.SessionImpl.Flush() at NHibernate.Impl.SessionImpl.FlushBeforeTransactionCompletion() at NHibernate.Impl.SessionImpl.BeforeTransactionCompletion(ITransaction tx) at NHibernate.Transaction.AdoTransaction.Commit() at NHibernate.Test.DriverTest.SqlServerCeDriverFixture.Query() in D:\BuildAgent\work\b0ecfa5dcda2234\src\NHibernate.Test\DriverTest\SqlServerCeDriverFixture.cs:line 97

Environment

None

Status

Assignee

Unassigned

Reporter

Frédéric Delaporte

Labels

None

Components

Fix versions

Affects versions

4.1.1

Priority

Minor
Configure