필터 지우기
필터 지우기

Running Simulink model in a loop causes Windows memory issues

조회 수: 15 (최근 30일)
Igor
Igor 2020년 4월 22일
댓글: Helder Magalhães 2021년 10월 21일
Hi,
I am running Simulink model in a loop to test various cases, i.e. do a sweep across range of parameters. My code is:
for i = 1:numColsVin
for j = 1:numColsRload
for k = 1:numColsfout
model = 'SimulinkModelv001';
load_system(model);
sim(model);
% Some code
end
end
end
After 10 or so iterations I have noticed that my disk memory increases, i.e. I get Windows warning that hard drive is running out of space and MATLAB closes. I have been running the same code on version 2012b, 2014b and 2015a never had similar issues. I am logging data, doing post-processing and printing after each iteration.
And when I say memory increase, it is more than 200 GB for 10 iterations!! I don't know where the data is located and I keep getting Windows warnings to remove some data from my hard drive. Only MATLAB was running when this happened. What is all that data? How to delete? How to disable from appearing? Is there any settings in the Simulink to prevent this?
Kind regards
  댓글 수: 3
Igor
Igor 2020년 4월 22일
No. I use signal logging in the Simulink model.
I was investigating a bit further the issue and it seems Temp file is the one causing the memory increase. In the last case it was 180 GB big. I have modified the code as shown below and for now I don’t see memory increase...
for i = 1:numColsVin
for j = 1:numColsRload
for k = 1:numColsfout
model = 'SimulinkModelv001';
load_system(model);
sim(model);
% Some code
close_system(model);
% tempdir
% Simulink.sdi.getSource
Simulink.sdi.clear % clear temp data
end
end
end
Helder Magalhães
Helder Magalhães 2021년 10월 21일
As stated, a fix is only available in R2021b; the proposed workaround is the one in the accepted answer (Simulink.sdi.clear).

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

채택된 답변

Igor
Igor 2020년 4월 23일
Adding close_system(model) and Simulink.sdi.clear after the code in each loop solved the problem.
for i = 1:numColsVin
for j = 1:numColsRload
for k = 1:numColsfout
model = 'SimulinkModelv001';
load_system(model);
sim(model);
% Some code
close_system(model);
% tempdir
% Simulink.sdi.getSource % location of stored temp data
Simulink.sdi.clear % clear temp data
end
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by