From help-octave-request at bevo dot che dot wisc dot edu Fri Feb 4 05:01:32 2000 Subject: Re: same mem problem From: "Erich Schneider" To: "help-octave at bevo dot che dot wisc dot edu" , "Guest9" Date: Fri, 04 Feb 00 12:11:49 Try this code and watch the memory usage: clear; f5hs3=rand(570,720)*5000; f5ls3=rand(570,720)*5000+1; C=-636.73*(f5hs3-f5ls3)./f5ls3-0.079098*f5hs3+332.15; clear f5ls3; [m,n]=size(f5hs3); C_temp1=C(2:2:m,2:2:n); clear C; C_temp=C_temp1(:); clear C_temp1; average=mean(C_temp(find(f5hs3(2:2:m,2:2:n)<3400))) clear C_temp; You could even subdivide the calculation for C into something like: c1 = f5hs3-f5ls3; c2 = -636.73.*c1./f5ls3; clear c1; C = c2+332.15-0.079098.*f5hs3; clear c2; I'm using 2.0.13, too, but couldn't reproduce your error when running your script repeatedly. It seems to me that for the calculation of C octave is storing 2 additional temporary matrices. Maybe subdividing this and clearing the accessible matrices cX helps. I recommend the step C_temp=C_temp1(:); clear C_temp1; because I saw the following behaviour of octave 2.0.13 and .14: a=ones(8000000,1); a=ones(8000000,1); memory exhausted bla ... b=ones(4000000,1); c=ones(4000000,1); If memory is exhausted then why can I execute the steps for b and c? I don't know whether this is a bug worth reporting or just a limitation based on how octave internally uses memory. However, I speculate that your problem rather seems to be related to the use of cygwin because I couldn't reproduce your error. On Linux, "clear" definitely frees the used memory and swap space. On Fri, 4 Feb 2000 12:26:56 +1300, Guest9 wrote: > > >Thanks Erich...it's running alot faster now; about 3 seconds for the calculation >as opposed to something like 12. Still now all that it means is that I get the >same memory problem again, just quicker. I've looked at task manager to see >what's happening as I went through the script line by line:- > >mem usage for octave > >2480 Kb start >5856 loaded first matrix - size 570x720 so this is ok 570x720x8 is >about 3200 K >9064 second matrix - ok >18768 calculated C -- so 570x720x24 = about 9600 K? Why 24 bytes >now? (forgive my ignorance) >18832 rest of minor calculations > >Ok, so apart from not understanding why it's 24, I can run the script through >once fine. When I try and run it a second time (after 'clear') it runs out of >memory. I was looking at a past help message that was similar to this and so >ran through the script lines a second time. After clear the mem usage stayed at >the 18832 Kb and didn't increase when I loaded the two matrices again, it was >trying to get C that it bombed. So what I'm asking is how can I actually >_clear_ the memory octave is using to run the script through again? ---------------------------------------------------------------------- Erich Schneider, Dipl.-Phys. | eschneider at nefo dot med dot uni-muenchen dot de Neurologische Forschung | u7x31ay at lrz-muenchen dot de Ludwig-Maximilians-Universit"at | Klinikum Grosshadern, M"unchen | Fax: +49,89,70906,101 ----------------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.che.wisc.edu/octave/octave.html How to fund new projects: http://www.che.wisc.edu/octave/funding.html Subscription information: http://www.che.wisc.edu/octave/archive.html -----------------------------------------------------------------------