Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 295629 - [spell checking] Dictionary remains in memory after spell checking is turned off
Summary: [spell checking] Dictionary remains in memory after spell checking is turned off
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.6 M5   Edit
Assignee: Deepak Azad CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-19 12:44 EST by Deepak Azad CLA
Modified: 2010-01-27 03:24 EST (History)
2 users (show)

See Also:


Attachments
fix (2.92 KB, patch)
2010-01-15 02:46 EST, Deepak Azad CLA
daniel_megert: review-
Details | Diff
fix (2.12 KB, patch)
2010-01-15 07:15 EST, Deepak Azad CLA
daniel_megert: review-
Details | Diff
fix (2.22 KB, patch)
2010-01-15 09:03 EST, Deepak Azad CLA
daniel_megert: iplog+
daniel_megert: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Deepak Azad CLA 2009-11-19 12:44:41 EST
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5
Build Identifier:  I20091117-1545

Dictionary remains in memory after spell checking is turned off. 

However when eclipse is restarted after disabling spell checking the dictionary is not loaded

Reproducible: Always

Steps to Reproduce:
1. Start Eclipse and open an editor
2. Turn on spell checking
3. Take a memory snapshot. SpellCheckEngine , LocaleSensitiveSpellDictioanry and other dictionary related object types are present.
4. Turn off spell checking
5. Objects mentioned in point 3 are still present.
Comment 1 Deepak Azad CLA 2010-01-15 02:46:34 EST
Created attachment 156204 [details]
fix

Created a listener on preference store, which shuts down the spellcheck engine when the spell check is disabled
Comment 2 Dani Megert CLA 2010-01-15 06:13:13 EST
Direction looks good. Two issues:
- Please use the same pattern as used for the JDT listener.
- Since each instance listens it should only shutdown itself and not the static
  instance. Just assume the class allows the creation of more than one 
  SpellCheckEngine: in that case you would only shutdown the global instance.
Comment 3 Deepak Azad CLA 2010-01-15 07:15:29 EST
Created attachment 156214 [details]
fix

(In reply to comment #2)
> Direction looks good. Two issues:
> - Please use the same pattern as used for the JDT listener.
Done

> - Since each instance listens it should only shutdown itself and not the static
>   instance. Just assume the class allows the creation of more than one 
>   SpellCheckEngine: in that case you would only shutdown the global instance.
Using shutdown() in place of SpellCheckEngine.shutdownInstance() causes a problem. In getInstance() fgEngine is not null when the spell check is enabled again after disabling it once. This results is spell check remaining disabled and eclipse needs to be restarted to enable spell check again.
Comment 4 Dani Megert CLA 2010-01-15 08:19:39 EST
As said before: each instance has to call shutdown on itself. To fix the issue you mentioned you can call the static method in case the instance itself is the singleton.

You're lucky that the default state of the engine is enabled, otherwise setting the values back to default (Restore Defaults) would cause a CCE because the property would be a string with value "false". Please read org.eclipse.jface.preference.IPreferenceStore.addPropertyChangeListener(IPropertyChangeListener) for details. The safest way to get the new value is to get the current value from the store.
Comment 5 Deepak Azad CLA 2010-01-15 09:03:52 EST
Created attachment 156221 [details]
fix
Comment 6 Dani Megert CLA 2010-01-18 06:02:25 EST
Committed patch to HEAD.
Available in builds > N20100117-2000.
Comment 7 Raksha Vasisht CLA 2010-01-27 03:24:34 EST
Verified for 3.6M5 with  I20100126-0800.