help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loops resource usage.


From: David Grohmann
Subject: Re: Loops resource usage.
Date: Thu, 21 Jun 2007 15:58:19 -0500
User-agent: Thunderbird 1.5.0.12 (Windows/20070509)

Muthiah Annamalai wrote:
Hello there,

I wanted to ask if there is a difference between writing a program like

for x=linspace(-pi:+pi,Npts)
   [X,Y,Z,L,M,N]=init_variables();
   do_a_time_consuming_long_computation();
 
  %clear the memory used
 
   clear all
end

% and this function?

for x=linspace(-pi:+pi,Npts)
   [X,Y,Z,L,M,N]=init_variables();
   do_a_time_consuming_long_computation();
end


My advisor told me, it saves something and does better in long programs.
Thanks in advance.

Thanks,
Muthu
PS: I couldnt find anything useful on this topic, in a Gmane search

_______________________________________________ Help-octave mailing list address@hidden https://www.cae.wisc.edu/mailman/listinfo/help-octave
I'm not too familiar with octave's internals but what you are basically saying is

start loop; do stuff; clear memory; loop back

versus

start loop; do stuff; loop back (implied that the octave reference counter/garbage collector will clear the memory for you in this case)

either way memory will be reclaimed when needed, I suspect doing a manual clear would actually slow things down, since you wont be able to amortize the garbage collection cost of more loop iterations.


I suppose the real answer is benchmark it and let us know which is faster.
-- 
David Grohmann
Senior Student Associate
Applied Research Lab : UT Austin : ESL - S206
Office: 512-835-3237


reply via email to

[Prev in Thread] Current Thread [Next in Thread]