Preventing Matlab/Simulink to Generate a Huge Temporary File

조회 수: 218 (최근 30일)
walli
walli 2018년 2월 1일
댓글: Reid Spence 2023년 11월 14일
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
Daniel Tegnered
Daniel Tegnered 2018년 7월 2일
Did you find a solution for this? I have the exact same issue, also moving from 2012b to 2017b.
Cheers, Daniel

댓글을 달려면 로그인하십시오.

답변 (7개)

Daniel Tegnered
Daniel Tegnered 2018년 7월 2일
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.
  댓글 수: 4
Sergey Kasyanov
Sergey Kasyanov 2022년 3월 11일
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 2023년 5월 30일
Parsim will automatically clear data from the DMR files after running all of the simulations. For more information refer to the following answer:

댓글을 달려면 로그인하십시오.


Frank Zhou
Frank Zhou 2019년 5월 15일
  댓글 수: 1
Tobias Huelsing
Tobias Huelsing 2019년 5월 16일
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?

댓글을 달려면 로그인하십시오.


Andres
Andres 2021년 9월 24일
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
Eugene Paymurzov
Eugene Paymurzov 2021년 12월 1일
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.

댓글을 달려면 로그인하십시오.


Tobias Huelsing
Tobias Huelsing 2018년 9월 11일
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 2018년 9월 11일
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 2018년 9월 11일
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 2023년 11월 14일
편집: Pegah Hosseini 2023년 11월 14일
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.
Simulink.sdi.setAutoArchiveMode(false);
Simulink.sdi.setArchiveRunLimit(0);
I also ran the below command but it does not delete the specified dmr file. It actually freezes on the below line.
Simulink.sdi.clear
Any ideas why above lines do not work? And any workaround?
Thanks
  댓글 수: 1
Reid Spence
Reid Spence 2023년 11월 14일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Dependency Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by