Preventing Matlab/Simulink to Generate a Huge Temporary File

314 visualizaciones (últimos 30 días)
walli el 1 de Feb. de 2018
Comentada: Reid Spence el 14 de Nov. de 2023
I've written a script which is performing a Simulink simulation in a cascaded for-loop structure. In each iteration the Simulink model structure is the same, but some model parameters change (system sensitivity analysis). After one simulation run I'm doing a little bit of post-processing and then the relevant data is stored as a .mat file on my HDD. The work space variables are overwritten each iteration and they stay the same size. The simulink model runs in ‘accelerated’ mode.
Unfortunately, Matlab is generating a huge temp file in ‘C:\Users\XXX\AppData\Local\Temp’ which is growing over time and reaches up to 100 GB – this is also when Matlab crashes due to a storage shortage on the partition. The temp file is named ‘XXX_sdi_4.6__none_eventLogging_1.2_sl_artifacts__sta_1.2__none.dmr’. I’ve tried to delete it after a couple of simulations from using the ‘delete’ command, but it doesn’t work (no permission). I’m pretty confused right now because I’ve done similar things in the past without that kind of issue – however, now I’ using Matlab 2017a while in the past I’ve mainly used 2012b. Was there maybe a major revision of the storage management between that versions?
Does anyone have a good guess how to prevent Matlab/Simulink generating such a huge temp file? Any idea is highly appreciated.
Cheers, Oliver
  1 comentario
Daniel Tegnered
Daniel Tegnered el 2 de Jul. de 2018
Did you find a solution for this? I have the exact same issue, also moving from 2012b to 2017b.
Cheers, Daniel

Iniciar sesión para comentar.

Respuestas (7)

Daniel Tegnered
Daniel Tegnered el 2 de Jul. de 2018
I had the same issue when running many Simulink simulations in a loop. Calling
to clear Data Inspector between runs solved the issue.
  4 comentarios
Sergey Kasyanov
Sergey Kasyanov el 11 de Mzo. de 2022
Also if you run simulation by parsim you can use CleanupFcn setting for delete .dmr files for each worker.
For example:
simout = parsim(simin, 'CleanupFcn', @Simulink.sdi.clear)
Reid Spence
Reid Spence el 30 de Mayo de 2023
Parsim will automatically clear data from the DMR files after running all of the simulations. For more information refer to the following answer:

Iniciar sesión para comentar.

Frank Zhou
Frank Zhou el 15 de Mayo de 2019
  1 comentario
Tobias Huelsing
Tobias Huelsing el 16 de Mayo de 2019
Thanks a lot for picking up the topic as this is still an issue with us.
If I understand the suggested solution correctly, this prevents SDI from archiving runs. In our case, we have one single HUGE simulation. Archive is empty because we see the problem already in the first simulation we are running.
I'll try:
I assume the solution is aimed at running numerous consecutive runs → Helps OP, but not us :-/ Any ideas on single runs?

Iniciar sesión para comentar.

Andres el 24 de Sept. de 2021
I have written some shortcut code to view and clear the SDI repository files and added it as a favourite command to my Quick Access Toolbar:
% SDI Clear: code to view and clear SDI repository files
sdiClearSC.tFolder = getenv('TMP');
sdiClearSC.dmrFiles = dir(fullfile(sdiClearSC.tFolder,'*.dmr'));
if isempty(sdiClearSC.dmrFiles)
sdiClearSC.answer = questdlg(["No *.dmr files found in ";...
"SDI Clear ShortCut",'Okay','Open folder anyway','Okay');
sdiClearSC.answer = questdlg(["*.dmr files found in ";
sdiClearSC.tFolder+ " :"; ...
" ";
string({}).' + ", " + ...
string(cat(1,sdiClearSC.dmrFiles.bytes)/pow2(20)) + " MiB";
" ";
"Clear SDI and repository files?"],...
"SDI Clear ShortCut",'Yes','No','No, open folder','Yes');
switch sdiClearSC.answer
case 'Yes'
disp('Clearing SDI, please wait...')
disp('... clearing SDI repository files, please wait...')
disp('... done.')
case {'Open folder anyway','No, open folder'}
clear sdiClearSC
  1 comentario
Eugene Paymurzov
Eugene Paymurzov el 1 de Dic. de 2021
Hi. Good solution. But sometimes matlab hang on the line sdi.Repository.clearRepositoryFile.
I turn off the Simulation Data Inspector does not automatically archive simulation runs. But the command Simulink.sdi.clear take very long time than I close matlab and open again.

Iniciar sesión para comentar.

Tobias Huelsing
Tobias Huelsing el 11 de Sept. de 2018
Hi, sorry for reopening the issue. I experience the same problem. But since I run a single simulation (10y sim time), I can't clear the SDI in between. Data logging is disabled and I cannot remove all log points as they are in 3rd party libraries. There has to be a solution since this is very annoying. At the moment, I have to fall back to older Matlab versions in which the models are not tested.

walli el 11 de Sept. de 2018
I'm guessing if you're actively using data logging for such an elaborate and long simulation you will face a problem with the data size. Hence, maybe you’ve to use down sampling or stop and restart you simulation in between and save the log data on some other available hard disk.

Tobias Huelsing
Tobias Huelsing el 11 de Sept. de 2018
Data logging is disabled (set_param(cfg.mdlName,'SignalLogging','off');) Data is stored via toWorkspace blocks with reduced decimation. It all works fine in Matlab 2013b. It is just the *.dmr file (see first post) from the data inspector.

Pegah Hosseini
Pegah Hosseini el 14 de Nov. de 2023
Editada: Pegah Hosseini el 14 de Nov. de 2023
Hi. I have a very large loop (100K) in which I run the same simulink model with slightly different settings. I check the time it takes to run every 1000 loops and I can see that as the loops increase, the time it takes to run a 1000 runs, gets longer and longer and I can only put it down to the dmr files getting larger.
I have the below two lines at the beginning of my script so I did not expect any temp files to be saved but I just found a 2G dmr in my temp folder which is getting larger with each iteration.
I also ran the below command but it does not delete the specified dmr file. It actually freezes on the below line.
Any ideas why above lines do not work? And any workaround?
  1 comentario
Reid Spence
Reid Spence el 14 de Nov. de 2023
What release are you using? In 20a there was a bug that prevented setArchiveRunLimit from working as expected
Also try updating to 22a latest update or later. There was an update to SDI infrastructure.

Iniciar sesión para comentar.


Más información sobre Simulink Environment Customization en Help Center y File Exchange.


Community Treasure Hunt

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

Start Hunting!

Translated by