Multiple Instances of MATLAB operating on Simulink Data Dictionaries can lead to crash or errors "database slddc is locked"

27 views (last 30 days)
I am running multiple MATLAB instance on my machine that operate on Simulink Data Dictionaries. This could be either:
  1. Multiple MATLAB's started at the same time by calling the matlab executable in a batch or similar script. 
  2. Multiple MATLAB workers using parfeval, parfor, etc and doing Simulink Data Dictionary operations on these workers.
In some cases I get this error:
The database \\?\C:\Users\rspence\AppData\Local\Temp\data_model_repository3.4_R2023b_v1_rspence.slddc is locked, or a table in the database is locked. (database is locked)
In other cases I get a MATLAB Crash where the stacktrace points to something in Simulink Data Dictionary.
What could be the cause?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 20 Aug 2025
Edited: MathWorks Support Team on 13 Oct 2025 at 13:06
Simulink Data Dictionaries use a cache file in the tempdir called the SLDDC file. These files assume only one MATLAB instance doing SLDD operations at a time. If multiple MATLAB instances try to access this file at the same time, it could lead to errors or crashes. 
To avoid this issue with multiple MATLAB Instances, give each MATLAB Instance its own tempdir. To do this, set the environment variable for the temporary directory before starting MATLAB. For Linux and MAC the temporary directory is set by the environment variable 'TMPDIR'. For Windows the environment variable is 'TEMP' and/or 'TMP'.
To avoid this issue for MATLAB workers in a Parallel Pool, use the function Simulink.data.dictionary.setupWorkerCache to give each worker its own Data Dictionary cache. Note that Simulink specific parallel functions like parsim, batchsim, and parallel build already do this setup for you. 

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!