quit doesn't quit the matlab when called from a loop.
이전 댓글 표시
Hello,
I am running a m-script that makes a lot of memory leak, and it reaches 2GB in about 3 hours. Since I am calling a lot of functions that somebody else created, I figured it is easier to just restart the function whenever it reaches memory maximum, and resume the loop. So, I implemented [!matlab -r myMscript] in the loop, but it won't quit so it won't free up the memory.
For example, the following script doesn't quit the matlab.
for i = 1:100,
if mod(i,20)==0,
!matlab -r test=1
quit
end
end
My matlab version is 7.7.0.471, and I have 64bit computer (Windows 7). The matlab is running with 32bit-mode.
Could anybody help me to dissovle this problem?
Best,
Ji Hyun
채택된 답변
추가 답변 (2개)
Sean de Wolski
2012년 3월 7일
Interesting idea. when you run:
!matlab
it halts execution in the current MATLAB instance until the new instance closes.
Daniel Shub
2012년 3월 7일
0 개 추천
I think Sean de gives the reason for your problem. As for a work around, I can think of a bunch of ways and it is really what you are most comfortable with. I think the key is to modify your script/function so that it only does a few loops and then exits. The "hard" part is letting the script figure out what loops to do. You could use the script name, check for an environment variable, pass an argument, etc).
Then you need to call the script/function, wait for it to end, and call the next one. If you have the parallel computing toolbox and/or a cluster, you could use a scheduler. I would probably write a shell script to do it. You could use MATLAB to do it.
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!