General questions about MCR caching behavior

I have a few general questions about the behavior of the MCR Cache.
  1. What creates the "mcrCache" folder? Which function in which toolbox?
  2. Why can the "mcrCache" folder appear under different paths? I am not making changes to the MCR_CACHE_ROOT variable. For example, my folder can appear under any of the following paths: \n
    C:\Users\<user>\AppData\Local\Temp\2\<user>\mcrCache9.7\nC:\Users\<user>\AppData\Local\Temp\<user>\mcrCache9.7\nC:\Users\<user>\AppData\Local\Temp\3\<user>\mcrCache9.7
  3. What deletes the cache folder, when does it get deleted, and how can I delete it cleanly?
  4. What is saved inside that cache folder?

 Accepted Answer

Please find answers to the questions below.
1. As part of executing the standalone program the CTF archive (MATLAB functions and data that define the application or library) is extracted to the cache directory. This action creates the folder. There is no toolbox function that does this; it is simply a necessary step that occurs when running the compiled application for the first time.
2. The path that the "mcrCache" folder is created in is determined by the system's $TEMP variable (unless you have specifically set MATLAB's MCR_CACHE_ROOT variable). It is unclear why this variable is changing when you execute your program multiple times. It is possible that you have some other program modifying the $TEMP variable, and as a result, you see different "mcrCache" paths above. It is also possible that you have multiple processes running your application, and Windows assigns a different $TEMP location to each process to avoid data reading/writing conflicts.
3. Nothing specifically deletes this cache folder. If the program is run again and the CTF archive has already been extracted to the cache folder, it will not be re-extracted, saving some time during the program's startup. You can delete the cache folder on your own at any time when the program is not running. To do this:
a. Get the path for the MCR cache by opening MATLAB and executing
>> mcrcachedir
b. Navigate to the path given above and delete the cache folder.
4. The CTF cache has the extracted CTF for compiled programs that have been run. This will include the user's code that was compiled into the application as well as a subset of that user's preferences. If preferences are modified during execution of the program, those modifications will persist in the cache.

More Answers (0)

Categories

Find more on Application Deployment in Help Center and File Exchange

Products

Release

R2021a

Community Treasure Hunt

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

Start Hunting!