Frank La Vigne

Fear and Loathing in .NET

MVP Logo
Tablet PC MVP

Social Networks

Subscription Options

Add to Google

Subscribe in Bloglines

My Links


Post Categories

Archives

Image Galleries


GamerTag

Dev Community Events

Blog Stats

 

News


Blog Roll

Favorite Sites

Gadget Blogs

Tablet PC Links

WPF TextBox Hogging Memory?

I came across this blog post from Marlon:

While running around in the WPF forums, I found this very interesting post… It seems that the WPF TextBox can be dangerous :) - if you do not use it carefully :)

Basically the TextBox by default stores all text changes in an Undo Stack… This implies that every time that you change the Text of the TextBox more memory is consumed by the TextBox.

In order to fix this you have to set the UndoLimit property to 0. This would disable the Undo feature for the TextBox and thus NO MORE MEMORY CONSUMPTION

The MSDN documentation on the UndoLimit property:

Setting UndoLimit clears the undo queue. When UndoLimit is set to –1, the undo queue is limited only by the memory that is available. When UndoLimit is set to 0, undo is disabled on the TextBoxBase.

UndoLimit is introduced in the .NET Framework version 3.5. For more information, see .NET Framework 3.5 Architecture.

Technorati Tags: ,,,,

posted on Sunday, February 17, 2008 2:20 PM