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

Francisco Figueiredo Jr. fxjrlists at yahoo.com.br
Sat Aug 28 00:27:29 EDT 2004

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 insert, 
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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: DbDataAdapter.diff
Type: text/x-patch
Size: 2280 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20040828/0dcec686/attachment.bin 

More information about the Mono-devel-list mailing list