Preventing Matlab/Simulink to Generate a Huge Temporary File

222 views (last 30 days)
walli
walli on 1 Feb 2018
Commented: Eugene Paymurzov on 1 Dec 2021 at 11:47
Hi,
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 Comment
Daniel Tegnered
Daniel Tegnered on 2 Jul 2018
Did you find a solution for this? I have the exact same issue, also moving from 2012b to 2017b.
Cheers, Daniel

Sign in to comment.

Answers (6)

Daniel Tegnered
Daniel Tegnered on 2 Jul 2018
I had the same issue when running many Simulink simulations in a loop. Calling
Simulink.sdi.clear
to clear Data Inspector between runs solved the issue.
  2 Comments

Sign in to comment.


Andres
Andres on 24 Sep 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 ";...
sdiClearSC.tFolder],...
"SDI Clear ShortCut",'Okay','Open folder anyway','Okay');
else
sdiClearSC.answer = questdlg(["*.dmr files found in ";
sdiClearSC.tFolder+ " :"; ...
" ";
string({sdiClearSC.dmrFiles.name}).' + ", " + ...
string(cat(1,sdiClearSC.dmrFiles.bytes)/pow2(20)) + " MiB";
" ";
"Clear SDI and repository files?"],...
"SDI Clear ShortCut",'Yes','No','No, open folder','Yes');
end
switch sdiClearSC.answer
case 'Yes'
disp('Clearing SDI, please wait...')
Simulink.sdi.clear
disp('... clearing SDI repository files, please wait...')
sdi.Repository.clearRepositoryFile
disp('... done.')
case {'Open folder anyway','No, open folder'}
winopen(sdiClearSC.tFolder)
end
clear sdiClearSC
  1 Comment
Eugene Paymurzov
Eugene Paymurzov on 1 Dec 2021 at 11:47
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.

Sign in to comment.


Tobias Huelsing
Tobias Huelsing on 11 Sep 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
walli on 11 Sep 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 on 11 Sep 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.

Frank Zhou
Frank Zhou on 15 May 2019
  1 Comment
Tobias Huelsing
Tobias Huelsing on 16 May 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:
Simulink.sdi.setAutoArchiveMode(false);
Simulink.sdi.setArchiveRunLimit(0);
I assume the solution is aimed at running numerous consecutive runs → Helps OP, but not us :-/ Any ideas on single runs?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!