[Mono-devel-list] DbDataAdapter fix for out of memory errors when filling datasets

S Umadevi sUmadevi at novell.com
Tue Aug 31 03:17:12 EDT 2004

  The patch looks ok for DbDataAdapater. Can you please go ahead and
commit it to the HEAD and the mono_1_0 branch..

Thanks for finding the problem.


>>> "Francisco Figueiredo Jr." <fxjrlists at yahoo.com.br> 8/28/2004
9:57:29 AM >>>

Hi all,

Here is a patch for handling out of memory exceptions when trying to 
fill datasets with queries which doesn't return a resultset like
delete, update.

The out of memory exception happens in the following line of 

around line 502.
int[] mapping = new int[reader.FieldCount]; // mapping the reader 
indexes to the datatable indexes

The problem is that when the query is an insert, update or delete, the

FieldCount property is -1 which gives the problem.

The compiler can detect when you try to create an array with a negative

index. But when this index is in a var, the runtime doesn't handle it 
and gives the error. The error is like that:

System.OutOfMemoryException: Out of memory.
in (unmanaged) (wrapper managed-to-native) 
System.Object:__icall_wrapper_mono_array_new_specific (intptr,int)
in <0x00004> (wrapper managed-to-native) 
System.Object:__icall_wrapper_mono_array_new_specific (intptr,int)
in <0x00091> System.Data.Common.DbDataAdapter:BuildSchema 
in <0x00079> (wrapper remoting-invoke-with-check) 
in <0x00086> System.Data.Common.DbDataAdapter:FillTable 
in <0x000ad> (wrapper remoting-invoke-with-check) 
in <0x0017d> System.Data.Common.DbDataAdapter:Fill 
in <0x000da> System.Data.Common.DbDataAdapter:Fill 
in <0x00049> System.Data.Common.DbDataAdapter:Fill 
in <0x0006b> (wrapper remoting-invoke-with-check) 
System.Data.Common.DbDataAdapter:Fill (System.Data.DataSet,string)

May I have to add a bugzilla entry?

The patch is attached.


Francisco Figueiredo Jr.

More information about the Mono-devel-list mailing list