Hi all, I am experiencing a strange "out of memory" exception when I close my app. All it does, is load a really large text (1 million characters) via stream reader from a .txt file into a rich textbox. The app takes ~80MB of RAM according to Task Manager.

The loading itself does not cause any problems / exceptions but when I close the app, the following exception occurs:

http://img490.imageshack.us/img490/7...sposing5wr.jpg


I tried myStreamReader.Close and RichTextBox1.Text = Nothing and still get the same exception.

When I run the app outside the IDE and then close it, it flickers for a second and closes normally without crashing. My guess is, this flickering is the exception.

The output from the debugger:
"
An unhandled exception of type 'System.OutOfMemoryException' occurred in mscorlib.dll

Unhandled Exception: OutOfMemoryException.
The program '[984] Chain' has exited with code 0 (0x0).
"

Any ideas how to prevent that thing, it can have some unknown strange effects later if I simply decide to ignore it.

Regards