MATLAB: Quit doesn’t quit the matlab when called from a loop.

for loopquit

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

Best Answer

Hi,
never thought about this way of doing this. You could try to do the following:
!matlab -r test=1 &
Note the & at the end of the line to not wait for the new instance to close.
Titus
Related Question