PDA

View Full Version : خطای argument exception was unhandled



armin8651
جمعه 20 اردیبهشت 1392, 19:45 عصر
در یک برنامه محاسبات خیلی زیادی در یک حلقه for انجام میدم و برنامه در حالت کلی اشکالی نداره ولی وسط اجرا بعد از حدود یک ساعت و نیم برنامه خطا میده. یک عکس از خطا گرفتم که تو لینک زیر میتونید اون رو ببینید:

http://upcity.ir/images2/85176265382592883105.png

اینم detail این خطا:


System.ArgumentException was unhandled
Message=Exception of type 'System.OutOfMemoryException' was thrown.Couldn't store <0> in 345 Column. Expected type is String.
Source=System.Data
StackTrace:
at System.Data.DataColumn.set_Item(Int32 record, Object value)
at System.Data.DataRow.set_Item(DataColumn column, Object value)
at System.Data.DataRow.set_Item(String columnName, Object value)
at WindowsApplication1.Form1.Button3_Click(Object sender, EventArgs e) in C:\Users\Armin\Desktop\Thesis programs\A\Thesis (A-TEXT)\Thesis\Form1.vb:line 257
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationCo ntext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[] commandLine)
at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.OutOfMemoryException
Message=Exception of type 'System.OutOfMemoryException' was thrown.
Source=mscorlib
StackTrace:
at System.Number.FormatInt32(Int32 value, String format, NumberFormatInfo info)
at System.Int32.ToString()
at System.Data.Common.StringStorage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)
InnerException:


میخوام بدونم علت این خطا چیه؟ اگه راه حل اون رو هم میدونید لطفا بگین.

beh_develop
شنبه 21 اردیبهشت 1392, 01:46 صبح
خطای outOfMemory هست
منطق برنامه تون رو چک کنین.
یک جای برنامه خیلی از حافظه استفاده می کنه که این جوری میشه.

armin8651
شنبه 21 اردیبهشت 1392, 14:57 عصر
خطای outOfMemory هست
منطق برنامه تون رو چک کنین.
یک جای برنامه خیلی از حافظه استفاده می کنه که این جوری میشه.

بله درسته تو برنامه یک کار رو چندین میلیون بار تکرار می کنم و داده های زیادی توی یک دیتاست نگه میدارم. این محاسبات باید انجام بشن و نمیشه ازشون صرف نظر کرد.
راه حل این حالت چیه؟
ممنون

h_a_m_i_d
شنبه 21 اردیبهشت 1392, 15:18 عصر
background worker
application.doevents
و .........

armin8651
شنبه 21 اردیبهشت 1392, 15:33 عصر
background worker
application.doevents
و .........

با application.doevents امتحان کردم باز هم این خطا رو داد.
با background worker هنوز امتحان نکردم. از نظر شما جواب میده؟ (هنگ کردن برنامه در هنگام اجرای دستورات مدنظر نیست)
ولی فکر نکنم این راهش باشه، چون کلا OutofMemory میده و به چند نخی بودن نباید ربطی داشته باشه
ممنون

h_a_m_i_d
شنبه 21 اردیبهشت 1392, 15:48 عصر
اگه کلا هدف کلی برنامه رو بگی
بیشتر میتونم کمکت کنم

armin8651
شنبه 21 اردیبهشت 1392, 17:17 عصر
اگه کلا هدف کلی برنامه رو بگی
بیشتر میتونم کمکت کنم
یک جدول تو دیتاست دارم با 645 ستون و حدود 188098 سطر. برای هر سلون جدول یک مقایسه انجام میده و بسته به اون مقدار 0 یا 1 توی اون خونه قرار میده، یعنی 645 * 188098 بار این کار رو انجام میده
برای مقادیر کوچکتر به درستی کار میکنه و برای این مقدار وسط اجرا بعد از یک ساعت و نیم این خطا رو میده. حالا دقیق نمیدونم مشکل از کجاست و چه جوری حل میشه!
ممنون

armin8651
یک شنبه 22 اردیبهشت 1392, 10:48 صبح
عنوان رو عوض کردم، این شاید بهتر باشه

خطای System.OutOfMemoryException


لطفا اگه اطلاعی در این زمینه دارید کمک کنید
ممنون

armin8651
یک شنبه 22 اردیبهشت 1392, 20:12 عصر
الگوریتم رو طوری نوشتم که حجم اطلاعات موجود تو رم کمتر بشه و تونستم برای داده های بزرگتر هم جواب بگیرم
تو لینک های زیر هم مطالبی تو این زمینه نوشته شده که میتونه مفید باشه:

http://www.codeproject.com/Questions/279316/How-To-Solve-System-out-of-memory-Exception

http://support.microsoft.com/kb/909678

http://stackoverflow.com/questions/1153702/system-outofmemoryexception-was-thrown-when-there-is-still-plenty-of-memory-fr