This is a migrated thread and some comments may be shown as answers.

Memory problems with multiple rich text editors with spelling enabled

6 Answers 116 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 23 Dec 2014, 05:12 AM
I have a form with multiple rich text editors, all with custom spell checking.
I did have this code to set the spell checker:
System.InvalidOperationExceptionvar culture = CultureInfo.GetCultureInfo("en-AU");
var checker = (DocumentSpellChecker)radRichTextEditor1.SpellChecker;
if (!(checker.GetDictionary(culture) is AustralianDictionary))
{
  checker.AddDictionary(AustralianDictionary.Instance, culture);
}
radRichTextEditor1.SpellChecker.SpellCheckingCulture = culture;

However, I found that I was using hundreds of megabytes of memory.
The work-around I used was to create a custom document spell checker:
public class CustomDocumentSpellChecker : DocumentSpellChecker
{
 
    // Thread-safe thanks to the CLR
    private static readonly CustomDocumentSpellChecker _instance = new CustomDocumentSpellChecker();
 
    private CustomDocumentSpellChecker()
    {
        var culture = CultureInfo.GetCultureInfo("en-AU");
        AddDictionary(AustralianDictionary.Instance, culture);
        SpellCheckingCulture = culture;
    }
 
    public static CustomDocumentSpellChecker Instance
    {
        get
        {
            return _instance;
        }
    }
}

I then assigned the custom spell checker to the rich text editor:
radRichTextEditor1.SpellChecker = CustomDocumentSpellChecker.Instance;

I'm hoping this approach is reasonable, and that the spell checker won't have a problem with being assigned to multiple rich text editors.

6 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 24 Dec 2014, 03:34 PM
Hi Jason,

Thank you for writing back.

Using a lot of memory does not necessarily mean that there is a memory leak. Before reporting such I would recommend you to test your application with a memory profiler. More information about this can be found here: Things to keep in mind when inspecting your application's memory usage.

In addition I cannot see any particular reason that you should not use the spell checker with several RadRichtextEditor controls (it appears that one cannot perform a simultaneous spellcheck on two controls). 

I hope this information helps. 

Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Jason
Top achievements
Rank 1
answered on 04 Jan 2015, 09:41 PM
Testing with a memory profiler is what led me to the above solution, after our testers reported getting out of memory exceptions.
It appears that the line:
    var checker = (DocumentSpellChecker)radRichTextEditor1.SpellChecker;
creates a new DocumentSpellChecker with its own custom dictionary.
The above work-around ensures that only one custom dictionary is created, and our memory problems are fixed.  This may not be suitable in every situation, but it may help someone.
0
Dimitar
Telerik team
answered on 07 Jan 2015, 03:52 PM
Hi Jason,

Thank you for writing back.

The specified line does create an new instance of DocumentSpellChecker but only if it is still not created (the first time you are getting it). The code looks like this:  
get
{
    if (this.spellChecker == null)
    {
        //other implementation omitted
        this.SpellChecker = new DocumentSpellChecker(customWordDictionary);
    }
 
    return this.spellChecker;
}

In your case perhaps you are using many controls and this is why the memory usage is large (this is not a memory leak). Nevertheless your solution is perfectly suitable since you can use the same spell checker with each control.

If you have any questions, please do not hesitate to contact us.
 
Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
daniel
Top achievements
Rank 1
answered on 04 Jan 2018, 09:16 AM

Hi,

i made a screen that contain a RadPageView with 7 pages and each page contain 1 RadRichTextEditor.

Would you advise me to use only 1 RadRichTextEditor because we can see only 1 at a time (I have some solution for that).

After reading your link "Things to keep in mind when inspecting your application's memory usage." (see above) it s seems it s not, but thank you for advising me.

I know it's a 4 years old post and i'll be Lucky if i have a response.

 

Regards,

Daniel

0
Dimitar
Telerik team
answered on 04 Jan 2018, 11:01 AM
Hi David,

I have tested this and there is no big difference in the initial memory usage (with 7 or 0 controls instances). The application can consume more memory if there a lot of loaded documents. But still, there should not be an issue with the memory. Please note that this depends on the user machines as well, and I would advise you to test the regular case on your side. For example, load 7 documents and see what is the memory consumption, if it can cause performance issue on your user machines consider loading one document at a time. 

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
daniel
Top achievements
Rank 1
answered on 04 Jan 2018, 01:00 PM

Hi,

thank you for answer.

Tags
RichTextEditor
Asked by
Jason
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Jason
Top achievements
Rank 1
daniel
Top achievements
Rank 1
Share this question
or