You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reported by diegot1106 on 2016-01-19 16:57 UTC
The **DatImagenativexferWindowsTwainDsm() **method in the **TWAIN **class makes a call to WindowsTwaindsmDsmEntryImagenativexfer that make the amount of ram to increase a lot. I scan in duplex mode (about 30 to 50 sheets/papers) and I always run out of memory.
Additional Details:
The method WindowsTwaindsmDsmEntryImagenativexfer is an external method located in "twaindsm.dll" so I don't know how to proceed and fix it.
The text was updated successfully, but these errors were encountered:
kolomiets
changed the title
OutOfMemoryException in call to WindowsTwaindsmDsmEntryUserinterface external method.
OutOfMemoryException in call to WindowsTwaindsmDsmEntryUserinterface external method. [sf#19]
Apr 5, 2017
Commented by diegot1106 on 2016-01-28 16:04 UTC
After intensive research, I found the solution so you can scan without getting memory overflow or OutOfMemoryException. Basically we need to dispose (Bitmap) and free resources (IntPtr). Basically the fixes should be done in two methods of the TWAIN class. Last advise is: Do not store each retrieved bitmap in a list in memory because it also takes a lot of memory
Class: TWAIN
Method: NativeToBitmap(Platform a_platform, IntPtr a:intptrNative)
Solution: Add these sentences after Bitmap bitmap = new Bitmap(bitmapStream);;
Class: TWAIN
Method:STS DatImagenativexfer(DG a_dg, MSG a_msg, ref Bitmap a_bitmap)
Solution: The if (sts == STS.XFERDONE) block should look like this:
if (sts == STS.XFERDONE)
{
// Bump our state...
m_state = STATE.S7;
// Turn the DIB into a Bitmap object...
// D.T. 25/01/2015 : This method also takes between 40 and 50 MB
// that needs to be cleaned.
a_bitmap = NativeToBitmap(ms_platform, intptrBitmap);
// We're done with the data we got from the driver...
//Marshal.FreeHGlobal(intptrBitmap);
//intptrBitmap = IntPtr.Zero;
DsmMemFree(ref intptrBitmap);
}
I'll write a more detailed and explained article on this, however not sure when but I will.
Thanks.
Diego Torres
Reported by diegot1106 on 2016-01-19 16:57 UTC
The **DatImagenativexferWindowsTwainDsm() **method in the **TWAIN **class makes a call to WindowsTwaindsmDsmEntryImagenativexfer that make the amount of ram to increase a lot. I scan in duplex mode (about 30 to 50 sheets/papers) and I always run out of memory.
Additional Details:
The method WindowsTwaindsmDsmEntryImagenativexfer is an external method located in "twaindsm.dll" so I don't know how to proceed and fix it.
The text was updated successfully, but these errors were encountered: