Development Environment    

Toolbox Path Caching

For performance reasons, MATLAB caches toolbox directory information across sessions. The caching features are mostly transparent to you. However, if MATLAB does not see the latest versions of your M-files or if you receive warnings about the toolbox path cache, you might need to update the cache.

Startup Using Cache File

Upon startup, MATLAB gets information from a cache file to build the toolbox directory cache. It displays the message

Using Toolbox Path Cache. Type "help toolbox_path_cache" for more info.

Because of the cache file, startup is faster, especially if you run MATLAB from a network server or if you have many toolbox directories. When you end a session, MATLAB updates the cache file.

MATLAB does not use the cache file at startup if you clear the Enable toolbox path cache check box in General Preferences. Instead, it creates the cache by reading from the operating system directories, which is slower than using the cache file.

Updating the Cache

How the Toolbox Path Cache Works.   MATLAB caches (essentially, stores in a known files list) the names and locations of files in $matlabroot/toolbox directories. These directories are for MathWorks supplied files that should not change except for product installations and updates. Caching those directories provides better performance during a session because MATLAB does not actively monitor those directories.

We strongly recommend that you save any M-files you create and any MathWorks-supplied M-files that you edit in a directory that is not in the $matlabroot/toolbox directory tree. If you keep your files in $matlabroot/toolbox directories, they may be overwritten when you install a new version of MATLAB.

When to Update the Cache.   When you add files to $matlabroot/toolbox directories, the cache and the cache file need to be updated. MATLAB updates the cache and cache file automatically when you install toolboxes or toolbox updates using the MATLAB installer. MATLAB also updates the cache and cache file automatically when you use MATLAB tools, such as when you save files from the MATLAB Editor to $matlabroot/toolbox directories.

When you add or remove files in $matlabroot/toolbox directories by some other means, MATLAB might not recognize those changes. For example, when you

MATLAB displays this message

You need to update the cache so MATLAB will recognize the changes you made in $matlabroot/toolbox directories.

Steps to Update the Cache.   To update the cache and the cache file

  1. Select File -> Preferences -> General.
  1. The General Preferences panel appears.

  1. Click Update Toolbox Path Cache and click OK.

Function Alternative.   To update the cache, use rehash toolbox. To also update the cache file, use rehash toolboxcache. For more information, see rehash.

Additional Diagnostics with Toolbox Path Caching

To display information about startup time when you start MATLAB, select the Enable toolbox path cache diagnostics in General Preferences.


  Adding Startup Options for UNIX Platforms Quitting MATLAB