WPF Spellcheck Engine takes up too much memory.

Posted by Matt H. on Stack Overflow See other posts from Stack Overflow or by Matt H.
Published on 2010-05-21T04:08:10Z Indexed on 2010/05/21 4:10 UTC
Read the original article Hit count: 383

Each datatemplate in my WPF ItemsControl contains FIVE custom bindable richtextbox controls.

It is a data-driven app that for authoring multiple-choice questions --> The question and four answer choices must all support: 1) Spell check 2) Rich formatting (otherwise I'd use regular textboxes)

The spell check object in .NET 4 has a Friend constructor that takes a single argument of owner As TextBoxBase This means every richtextbox in the ItemsControl has 5 Spellcheck objects!

This is the problem --> every spell check engine is consuming about 500k memory. So after you favor in the spellcheck, bindings, additional controls in the DataTemplate, etc.. a single multi choice question consumes more than 3MB memory.

Users with 100-->200 questions will quickly see the App raise it's memory consumption to 500+ MB. Management is definitely not OK with this.

Is there a way to minimimze this problem? The best suggestion I've heard is to enable/disable spellcheck if the richtextbox is in the ItemsControl's scrollviewer: I haven't gotten an answer to how to go about it: (http://stackoverflow.com/questions/2869012/possible-to-implement-an-isviewportvisible-dependencyproperty-for-an-item-in-an-i)

Any good ideas?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about vb.net