What happens on Ctrl + C?
조회 수: 9 (최근 30일)
이전 댓글 표시
I have a problem that my code becomes slower with each iteration (I used a profiler, it is none of the usual culprits: unclosed figures or non-preallocated arrays). If I click Ctrl+C and continue where I started, it runs quickly again. Can someone please tell me what exactly happens on Ctrl+C? I tried writing my variables into a file, clearing all and re-starting, but it didn't help. I would like to know which function is called on this command so I can reproduce this behavior.
댓글 수: 6
Philip Borghesani
2017년 12월 4일
Some additional information would help here: What MATLAB version are you using and are you using any custom MEX files?
채택된 답변
Philip Borghesani
2017년 12월 4일
Two things happen when MATLAB returns back to the command line:
- Memory leaked by any mex files is cleaned up (mxMalloc... or MATLAB arrays). The best practice is to only rely on automatic clean up in the event of an error.
- Any pending display/graphics messages are processed by MATLAB. This can be forced by adding a drawnow to your code. In general this should not cause an issue because there should not be a huge number of events pending but there have been bugs in the distant past.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!