[Top][All Lists]

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

memory problem

From: John W. Eaton
Subject: memory problem
Date: Tue, 10 Jun 1997 12:58:00 -0500

On  5-Jun-1997, Stef Pillaert BK <address@hidden> wrote:

| I've written a (rather big) program, using scripts (and I'm
| using octave-2.0.6 now). The program is a main function, and from that
| function I call a lot of other functions (with a few levels of
| nesting...). Since I need a few big matrices, I declare them as global
| variables, thus hoping to avoid unnecessary copies of them...

It's not necessary to use global variables for this purpose.  Even
though the semantics of Octave's parameter passing mechanism is call
by value, copies are only made when necessary (for example, if a
variable that appears in an argument list is is modified inside a

| What's my problem? When I'm solving big problems (i.e. big matrices) with
| my program, I get a message like 'memory exhausted'. I'm trying to figure
| out why I get the memory problem, because it seemed that memory was
| "growing" where I didn't expect it.
| I also tried a smaller problem (i.e. smaller matrices), but when I
| calculate my problem over and over again (i.e. from my main function I
| keep calling the "sub-functions" over and over again), I also have memory
| problems: "error: out of dynamic memory in yy_create_buffer();". This is
| difficult to understand for me, because I get this message only after a
| lot of calls of the sub-functions (so the first time I calculate
| it, everything goes fine, but repeating the same process over and over
| again gets me in trouble...)
| Is there an easy way for me to detect what exactly is "growing"? Can I
| check how "big" (in Bytes) every variable is? 
| I'm sorry that this message isn't very detailed, but my program is so big
| that it's very complicated for me to trace where my problems come from.
| I've tried to check (as much as possible with "whos") wether my global
| variables aren't "growing", and that "seems" to be O.K. 

There may or may not be a bug in Octave.  It's impossible to tell
without seeing the code that you are actually using.

One common mistake that can cause Octave to consume a lot of memory is
building matrices with code like this:

  result = [];
  for i = ever:and_ever
    result = [ result, new_value() ];

instead of

  result = zeros (big_n, big_m);
  for i = over:and_over
    r1 = ...
    r2 = ...
    result (r1, r2) = new_value ();

because code like the first example requires Octave to reallocate
space in increasingly larger chunks, and the smaller chunks are often
not suitable for reuse by the memory allocator.

If you think there is a bug in Octave that results in a memory leak,
please submit a complete bug report to address@hidden
that includes enough information so that I can reproduce the problem.



reply via email to

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