# How can I speed up the Editor when editing relatively large files in MATLAB 7.9 (R2009b) and later releases?

45 views (last 30 days)
I am trying to edit a large MATLAB file (e.g. approximately 8000 lines of code) in the MATLAB Editor window. However, the editor is very slow to respond to keyboard input. There is a significant delay between a key press and the display of the character on the screen.
I have disabled the following features from the Preferences - M-lint (R2009b) or Code Analyzer (R2010a and after), Autosave, Code-folding and Syntax highlighting. Additionally, I have also tried increasing the Java heap space but I do not see a performance improvement.

MathWorks Support Team on 21 Jan 2021
Edited: MathWorks Support Team on 22 Jan 2021
The slow Editor performance for large files can be attributed to internal processes (MTree) that MATLAB runs to check on the code for potential errors and problems.
If possible, try to split up long code into multiple files. This will improve readability in addition to performance. For more details on general ways to improve performance, please refer to the link below:
If reducing the size of the file is not an option, disabling all features that utilize MTree in the editor would resolve the issue. These features include code analyzer, cell mode, variable highlighting, quick rename, and more. Note that the workaround below for disabling these features should be used with care as it does not provide the user with any notification on the fact that the feature that utilize MTree are disabled.
If you are using MATLAB 7.9 (R2009b) or beyond, please read the appropriate section below.
=================================================
For MATLAB 7.13 (R2011b) and newer releases
=================================================
If you are using MATLAB 7.13 (R2011b) or a newer release, please follow the steps below to disable all features that utilize MTree in the editor:
1) At the MATLAB prompt, type the following command:
com.mathworks.services.Prefs.setBooleanPref('CodeParserServiceOn',false)
2) Restart MATLAB to reset any cached data.
3) Please be sure to re-enable the features that utilize MTree after editing large files by executing the following command at the MATLAB prompt and then restarting MATLAB:
com.mathworks.services.Prefs.setBooleanPref('CodeParserServiceOn',true)
If the above did not help, try the following steps in addition to the steps above:
1) At the MATLAB prompt, type the following command:
com.mathworks.services.Prefs.setIntegerPref('CodeParserServiceFileSizeLimit',300)
In the above, the number "300" refers to the maximum number of lines an M-file contains before MTree related code parsing is disabled. Adjust this number according to the number of lines in your script.
2) Restart MATLAB to reset any cached data.
3) Re-enable the code parsing features for other files by executing the following commands (which resets the file size limit to the default and enables parsing) and restarting MATLAB:
com.mathworks.services.Prefs.setBooleanPref('CodeParserServiceOn',true)
com.mathworks.services.Prefs.setIntegerPref('CodeParserServiceFileSizeLimit',0)
Some customers have reported that switching to the Oracle JRE instead of the one with OpenJDK has also helped speed up the Editor.
=================================================
For MATLAB 7.9 (R2009b) up to MATLAB 7.12 (R2011a)
=================================================
If you are using a version of MATLAB from MATLAB 7.9 (R2009b) to MATLAB 7.12 (R2011a) included, please download the patch corresponding to the version of MATLAB you are using and follow the steps below:
1) Close MATLAB if it is running
2) Navigate to the following directory:
$MATLABROOT\java\ where$MATLABROOT is the output of typing 'matlabroot' at the MATLAB prompt.
3) Create a folder named 'patch' if it does not already exist.
$MATLABROOT\java\patch The file 'MTreeBaseDocumentCache.class' should be located in the following directory:$MATLABROOT\java\patch\com\mathworks\widgets\text\mcode
5) Launch MATLAB. At the MATLAB prompt, type the following command:
com.mathworks.services.Prefs.setBooleanPref('CodeParserServiceOn',false)
6) Restart MATLAB to reset any cached data.
7) Please be sure to re-enable the features that utilize MTree after editing large files by executing the following command at the MATLAB prompt and then restarting MATLAB:
com.mathworks.services.Prefs.setBooleanPref('CodeParserServiceOn',true)

R2008a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!