RichTextBox requires tons of memory for text

  • Thread starter Thread starter Walter L. Williams
  • Start date Start date
W

Walter L. Williams

VS.NET 2K3 and .NET 1.1

I'm having a problem with RichTextBox allocating huge amounts of memory for
text. I have recreated the problem in the attached sample which, when the
button is pressed, will create a ~33MB file and load it into the
RichTextBox.

If you watch the memory in Task Manager, before the button it consumes ~15MB
max, but after it's finished, the memory is upwards of 140MB. Immediately
invoking the GC doesn't seem to help. I've tried different things to no
avail.

Strangely enough, if I minimize the window, or maximize and restore, it will
go down to something I could at least understand.

I thought it might be related to http://support.microsoft.com/?kbid=826981,
which fix was included in the recently released SP1. I retested the issue
using the service pack, but it's still there.

What can I do to fix this?

====================================================
Walter Williams
Software Engineer
Sawtooth Software, Inc.
http://www.sawtoothsoftware.com
 
This is not a .NET issue, but the normal behavior of the RichTextBox
control, the memory is taken from the unmanaged heap. Just load your
textfile into Wordpad (don't even try to load it in Winword as it exceeds
the number of pages Word can handle), make sure to scroll to the last line
and watch the bytes used in taskman.


Willy.
 
Back
Top