|
From: | Brian Blais |
Subject: | Re: Questions about memory usage.. |
Date: | Wed, 20 Apr 2005 11:05:18 -0400 |
User-agent: | Mozilla Thunderbird 0.8 (X11/20040913) |
Etienne de Foras wrote:
Hello, I am working on huges matrix and would like to know how octave manage them in memory: With examples: a=rand(10000,10000) (or a huge matrix); - b=a; # will it copy in memory or just make a reference? - c.toto=a ; # will it copy in memory or just make a reference? - d=reshape(a,....) # will it copy in memory or just make a reference? - f=a(:) # will it copy in memory or just make a reference? - g=a'; # will it copy in memory or just make a reference? - the same in a function?
Although a hack, the way I answer these questions (on Linux) is to open up another terminal and run 'top', sort by memory usage, and put pause commands in between each line. The first line pushes the memory up to a certain amount. every line (other than your last example) doesn't allocate more memory, so it must make a reference (unless the variable is changed, like d(3)=5). The last line, transpose, seems to make a copy.
One can always go through the code, but I think this method works as a quick hack answer decently.
Brian Blais -- ----------------- address@hidden http://web.bryant.edu/~bblais ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------
[Prev in Thread] | Current Thread | [Next in Thread] |