[Mono-dev] TextBoxBase Out of Memory Problem

Sebastien Pouliot sebastien.pouliot at gmail.com
Fri Jan 19 22:09:52 EST 2007


Hello Charlie,

Are you using Mono from SVN ? (if so which revision ?) or stock 1.2.2 ?

I believe I fixed today this problem (it affects only Win32). The DC was
not released because the p/invoke signature missed a parameter.

Sebastien

On Fri, 2007-01-19 at 18:23 -0800, Charlie Poole wrote:
> Hi All,
> 
> While it's probably not a good idea to keep hitting a text box with
> AppendText calls, that's what the NUnit Gui does at the moment, resulting
> in the stack trace below.
> 
> This is a bit hard to repro, since NUnit tries to handle the unhandled 
> exception, making matters even worse. I got it by running the NUnit tests
> with labels turned on, so that each test caused at least one write to the
> output tab. To get the stack trace, I modified NUnit to not capture
> unhandled exceptions and ran it under mono with --debug. If this is not
> already a known problem, I can try to create a simple test for it.
> 
> Charlie
> 
> 
> D:\Dev\NUnit\nunit-2.4\build\mono\1.0\debug>mono --debug nunit.exe
> 
> Unhandled Exception: System.Reflection.TargetInvocationException: Exception
> has
> been thrown by the target of an invocation. --->
> System.Reflection.TargetInvocat
> ionException: Exception has been thrown by the target of an invocation. --->
> Sys
> tem.OutOfMemoryException: Out of memory.
>   at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00078] in
> C:\cygwin\t
> mp\scratch\mono-1.2.2\mcs\class\System.Drawing\System.Drawing\gdipFunctions.
> cs:1
> 92
>   at System.Drawing.Graphics.FromHdc (IntPtr hdc) [0x00009] in
> C:\cygwin\tmp\scr
> atch\mono-1.2.2\mcs\class\System.Drawing\System.Drawing\Graphics.cs:1673
>   at System.Drawing.Font.ToLogFont (System.Object logFont) [0x0007a] in
> C:\cygwi
> n\tmp\scratch\mono-1.2.2\mcs\class\System.Drawing\System.Drawing\Font.cs:620
>   at System.Drawing.Font.ToHfont () [0x00059] in
> C:\cygwin\tmp\scratch\mono-1.2.
> 2\mcs\class\System.Drawing\System.Drawing\Font.cs:267
>   at (wrapper remoting-invoke-with-check) System.Drawing.Font:ToHfont ()
>   at System.Windows.Forms.XplatUIWin32.GetFontMetrics
> (System.Drawing.Graphics g
> , System.Drawing.Font font, System.Int32& ascent, System.Int32& descent)
> [0x0001
> 3] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\Managed.Windows.Forms\System.Wi
> ndows.Forms\XplatUIWin32.cs:2019
>   at System.Windows.Forms.XplatUI.GetFontMetrics (System.Drawing.Graphics g,
> Sys
> tem.Drawing.Font font, System.Int32& ascent, System.Int32& descent)
> [0x00000] in
>  
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\Managed.Windows.Forms\System.Wind
> ows
> .Forms\XplatUI.cs:516
>   at System.Windows.Forms.Line.RecalculateLine (System.Drawing.Graphics g,
> Syste
> m.Windows.Forms.Document doc) [0x002dd] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\
> class\Managed.Windows.Forms\System.Windows.Forms\TextControl.cs:525
>   at System.Windows.Forms.Document.RecalculateDocument
> (System.Drawing.Graphics
> g, Int32 start, Int32 end, Boolean optimize) [0x0007f] in
> C:\cygwin\tmp\scratch\
> mono-1.2.2\mcs\class\Managed.Windows.Forms\System.Windows.Forms\TextControl.
> cs:3
> 791
>   at System.Windows.Forms.Document.RecalculateDocument
> (System.Drawing.Graphics
> g) [0x00000] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\Managed.Windows.Forms
> \System.Windows.Forms\TextControl.cs:3745
>   at System.Windows.Forms.TextBoxBase.CalculateDocument () [0x0000c] in
> C:\cygwi
> n\tmp\scratch\mono-1.2.2\mcs\class\Managed.Windows.Forms\System.Windows.Form
> s\Te
> xtBoxBase.cs:1591
>   at System.Windows.Forms.TextBoxBase.AppendText (System.String text)
> [0x00077]
> in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\Managed.Windows.Forms\System.Wind
> o
> ws.Forms\TextBoxBase.cs:639
>   at <0x00000> <unknown method>
>   at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke
> (ob
> ject,object[])
>   at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags
> invoke
> Attr, System.Reflection.Binder binder, System.Object[] parameters,
> System.Global
> ization.CultureInfo culture) [0x00040] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\c
> lass\corlib\System.Reflection\MonoMethod.cs:143 --- End of inner exception
> stack
>  trace ---
> 
>   at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags
> invoke
> Attr, System.Reflection.Binder binder, System.Object[] parameters,
> System.Global
> ization.CultureInfo culture) [0x00065] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\c
> lass\corlib\System.Reflection\MonoMethod.cs:149
>   at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[]
> par
> ameters) [0x00000] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\corlib\System.R
> eflection\MethodBase.cs:86
>   at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00051] in
> C:\cy
> gwin\tmp\scratch\mono-1.2.2\mcs\class\corlib\System\Delegate.cs:285
>   at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args)
> [0x00018]
>  in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\corlib\System\MulticastDelegate.c
> s:67
>   at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in
> C:\cygwin
> \tmp\scratch\mono-1.2.2\mcs\class\corlib\System\Delegate.cs:257
>   at System.Windows.Forms.Control.Invoke (System.Delegate method,
> System.Object[
> ] args) [0x0000b] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\Managed.Windows.
> Forms\System.Windows.Forms\Control.cs:2931
>   at (wrapper remoting-invoke-with-check)
> System.Windows.Forms.Control:Invoke (S
> ystem.Delegate,object[])
>   at NUnit.UiKit.TextBoxWriter.AppendToTextBox (System.String s) [0x00000]
> in D:
> \Dev\NUnit\nunit-2.4\src\GuiComponents\UiKit\TextBoxWriter.cs:176
>   at NUnit.UiKit.TextBoxWriter.Write (System.String s) [0x00034] in
> D:\Dev\NUnit
> \nunit-2.4\src\GuiComponents\UiKit\TextBoxWriter.cs:125
>   at NUnit.UiKit.TextBoxWriter.Write (Char c) [0x00000] in
> D:\Dev\NUnit\nunit-2.
> 4\src\GuiComponents\UiKit\TextBoxWriter.cs:108
>   at System.IO.TextWriter.Write (System.Char[] buffer, Int32 index, Int32
> count)
>  [0x0004f] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\corlib\System.IO\TextWr
> iter.cs:201
>   at System.IO.TextWriter.Write (System.Char[] value) [0x00008] in
> C:\cygwin\tmp
> \scratch\mono-1.2.2\mcs\class\corlib\System.IO\TextWriter.cs:128
>   at System.IO.TextWriter.WriteLine () [0x00000] in
> C:\cygwin\tmp\scratch\mono-1
> .2.2\mcs\class\corlib\System.IO\TextWriter.cs:217
>   at System.IO.TextWriter.WriteLine (System.String format, System.Object
> arg0) [
> 0x00008] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\corlib\System.IO\TextWrit
> er.cs:297
>   at NUnit.UiKit.ResultTabs.OnTestStarting (System.Object sender,
> NUnit.Util.Tes
> tEventArgs args) [0x00016] in
> D:\Dev\NUnit\nunit-2.4\src\GuiComponents\UiKit\Res
> ultTabs.cs:376
>   at <0x00000> <unknown method>
>   at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke
> (ob
> ject,object[])
>   at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags
> invoke
> Attr, System.Reflection.Binder binder, System.Object[] parameters,
> System.Global
> ization.CultureInfo culture) [0x00040] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\c
> lass\corlib\System.Reflection\MonoMethod.cs:143 --- End of inner exception
> stack
>  trace ---
> 
>   at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags
> invoke
> Attr, System.Reflection.Binder binder, System.Object[] parameters,
> System.Global
> ization.CultureInfo culture) [0x00065] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\c
> lass\corlib\System.Reflection\MonoMethod.cs:149
>   at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[]
> par
> ameters) [0x00000] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\corlib\System.R
> eflection\MethodBase.cs:86
>   at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00051] in
> C:\cy
> gwin\tmp\scratch\mono-1.2.2\mcs\class\corlib\System\Delegate.cs:285
>   at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args)
> [0x00018]
>  in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\corlib\System\MulticastDelegate.c
> s:67
>   at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in
> C:\cygwin
> \tmp\scratch\mono-1.2.2\mcs\class\corlib\System\Delegate.cs:257
>   at System.Windows.Forms.XplatUIDriverSupport.ExecuteClientMessage
> (GCHandle gc
> handle) [0x0003d] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\Managed.Windows.
> Forms\System.Windows.Forms\XplatUIDriver.cs:335
>   at System.Windows.Forms.XplatUIWin32.GetMessage (System.Windows.Forms.MSG&
> msg
> , IntPtr hWnd, Int32 wFilterMin, Int32 wFilterMax, Boolean blocking)
> [0x00131] i
> n
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\Managed.Windows.Forms\System.Wind
> ow
> s.Forms\XplatUIWin32.cs:1532
>   at System.Windows.Forms.XplatUIWin32.GetMessage (System.Object queue_id,
> Syste
> m.Windows.Forms.MSG& msg, IntPtr hWnd, Int32 wFilterMin, Int32 wFilterMax)
> [0x00
> 000] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\Managed.Windows.Forms\System.
> Windows.Forms\XplatUIWin32.cs:1480
>   at System.Windows.Forms.XplatUI.GetMessage (System.Object queue_id,
> System.Win
> dows.Forms.MSG& msg, IntPtr hWnd, Int32 wFilterMin, Int32 wFilterMax)
> [0x00000]
> in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\Managed.Windows.Forms\System.Wind
> o
> ws.Forms\XplatUI.cs:527
>   at System.Windows.Forms.Application.RunLoop (Boolean Modal,
> System.Windows.For
> ms.ApplicationContext context) [0x002be] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs
> \class\Managed.Windows.Forms\System.Windows.Forms\Application.cs:552
>   at System.Windows.Forms.Application.Run (System.Windows.Forms.Form
> mainForm) [
> 0x00000] in
> C:\cygwin\tmp\scratch\mono-1.2.2\mcs\class\Managed.Windows.Forms\Sys
> tem.Windows.Forms\Application.cs:430
>   at NUnit.Gui.AppEntry.Main (System.String[] args) [0x001d1] in
> D:\Dev\NUnit\nu
> nit-2.4\src\GuiRunner\nunit-gui\AppEntry.cs:123
>   at NUnit.Gui.Class1.Main (System.String[] args) [0x00000] in
> D:\Dev\NUnit\nuni
> t-2.4\src\GuiRunner\nunit-gui-exe\Class1.cs:16
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list