help-octave
[Top][All Lists]
Advanced

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

Re: memory management on Octave + writing .oct files


From: Agnes Bousquier
Subject: Re: memory management on Octave + writing .oct files
Date: Mon, 20 Mar 2006 11:57:13 +0100
User-agent: Thunderbird 1.5 (Windows/20051201)

Hello,

 Thank you very much to J.W Eaton and Q.Spencer for their replies.
In fact, I have to read frames coming from a .avi file in my program, so I wrote the Octave script "testaviread.m" to test two ways of doing it: _ uncommenting the lines 5 to 7 (the "for" loop) and commenting the line 10 (testavirec(1,50);) will make Octave read the frames thanks to a "for" loop; in fact, this solution is slow, but do not use much memory on my Windows XP system; _ in the other hand, I call the function "testavirec"; it reads the frames on a recursive way, and so is supposed to run faster than a "for" loop. But the problem is that when my function reads the (k+1)th frame, it does not delete the kth from the memory, and so my system slows down... Finally this method is slower than the first because of this memory management problem; but maybe is this issue due to the fact that I use Octave under Cygwin, and so it has no "real" access to virtual memory?

Best regards,

Agnes

Quentin Spencer a écrit :
Agnes Bousquier wrote:

Hello everybody,

I am facing problems of slowness with my .m files, so I tried several ways to make them run faster, and have some questions :

1- Are there any routines which allows us to manage memory on Octave (like "malloc" and "free" for C language)?


If you want to pre-allocate arrays (which does increase speed in some cases), simply create an array of the correct dimensions using the zeros command. Using the "clear" command will clear an array from memory, and so is roughly equivalent to "free".

2- About .oct files : what should I do to call an Octave's function (like imshow) in a .oct file?

I don't know if it works for m files, but if you have another oct file function called func, you can call it from C using Ffunc.

Another general comment about speed in octave: make sure you are using vector functions where possible to avoid for loops. Seeing ways to do so takes a lot of familiarity with the language--some of the functions I wrote in the first years after I learned Matlab were much slower than they could have been. If you have specific examples of code that is slow, you could see if anyone here knows ways to make it faster.

-Quentin



-------------------------------------------------------------
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
-------------------------------------------------------------





-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

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