Memory usage in octave

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Memory usage in octave

Steven W. Sumner
I am trying to understand how octave's memory usage works.  I have a
simple program and function file which I have attached (see below) that
seems to be leaking memory.  The same program called in matlab leaks no
memory.  Could someone explain the logic of memory usage in this simple
program.  I have a much larger and more complex program with calls to
.oct files and functions, which also leaks memory.  

The main program file (testmem.m) has the following lines of code:

for i=1:500,
  x=rand(250);
  xy=testfun(x);
  clear
end

___________________________________________________________

The function file (testfun.m) contains the following code:

function xx = testfun(p)

  xx=p+p;
  xx(1:100,:)=[];
  xx(:,1:100)=[];

return


When this program is run in matlab it takes up 8488K (as measured by top
running on a unix workstation Solaris 2.5.1).  In Octave (2.0.13) it
starts out using 9208K but grows by the 500th time through the loop to
9416K.  What is causing this memory leak?

Also, I thought it was odd that the clear command did not also delete
the counter "i" and cause the program to bomb.  Why does this not occur.

Any insights into memory usage in octave would be appreciated.

Thanks,

Steve Sumner
Federal Reserve Board