Memory....

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Memory....

Stef Pillaert BK-2
Hello,

I've written a program where I use a lot of big matrices.
The program is a big function, where I call a lot of other functions, like
this:

function retval=program(....)
  function1(...);
  function2(...);
  ....
  function12(...);
endfunction

Each of those functions call a lot of other functions, with a lot of
loops.

At a certain stage, I run out of memory, and the program halts. Indeed,
when I follow what's happening (using Linux "top") , I can see that the
"Size" is growing and growing, and at the end becoming too big for the
available memory....

However, when I change my program to:

function retval=program(...)
  function1(...);
  function2(...);
  ....
  save file1 *;
  function12(...);
endfunction

this is what happens: the program halts (of course), but using the "save
*" I saved all (?) variables. Then I quit octave, I restart octave, I load
file1, and I execute function12 without any problem! "Size" (using top) is
also a lot smaller (about 50%).

Is this behaviour by octave normal (I'm not sure about the "save *": does
it save everything? I suppose there is an amount of memory taken by the
functions I call, but can it be that much?). Can I do some other checking
to find out what I'm doing wrong? It's very hard for me to trace down
what's going on, because the results I get from the program are quite
OK, so... Also the file1 seems to have everything I expect it to
have. Has this something to do with precision used with save and load?

(I'm not using any recursion, and I'm not using loops like this (any
more..):

retval=[]
for i=1:times
  retval=[retval;some_matrix];
endfor

I do call the same functions over and over again, I use a lot of "eval" (I
know it's slowing down things, but I have my reasons for this)).

If you think you can help me, thanks very much.

Stef.




Reply | Threaded
Open this post in threaded view
|

Memory....

John W. Eaton-6
On 29-Aug-1997, Stef Pillaert BK <[hidden email]> wrote:

| I've written a program where I use a lot of big matrices.
| The program is a big function, where I call a lot of other functions, like
| this:
|
| function retval=program(....)
|   function1(...);
|   function2(...);
|   ....
|   function12(...);
| endfunction
|
| Each of those functions call a lot of other functions, with a lot of
| loops.
|
| At a certain stage, I run out of memory, and the program halts. Indeed,
| when I follow what's happening (using Linux "top") , I can see that the
| "Size" is growing and growing, and at the end becoming too big for the
| available memory....

The behavior you report may be due to a bug in Octave, but it is
impossible to say for sure, because you haven't provided enough
information for anyone to be able to reproduce the problem.

Please submit a complete bug report to [hidden email],
including everything necessary to reproduce the problem.  See the
section in the Octave manual on reporting bugs for more information
about what makes a useful bug report.

Thanks,

jwe


Reply | Threaded
Open this post in threaded view
|

Re:Re: Memory....

Stef Pillaert BK-2


On Fri, 29 Aug 1997, John W. Eaton wrote:

> On 29-Aug-1997, Stef Pillaert BK <[hidden email]> wrote:
>
> | I've written a program where I use a lot of big matrices.
> | The program is a big function, where I call a lot of other functions, like
> | this:
> |
> | function retval=program(....)
> |   function1(...);
> |   function2(...);
> |   ....
> |   function12(...);
> | endfunction
> |
> | Each of those functions call a lot of other functions, with a lot of
> | loops.
> |
> | At a certain stage, I run out of memory, and the program halts. Indeed,
> | when I follow what's happening (using Linux "top") , I can see that the
> | "Size" is growing and growing, and at the end becoming too big for the
> | available memory....
>
> The behavior you report may be due to a bug in Octave, but it is
> impossible to say for sure, because you haven't provided enough
> information for anyone to be able to reproduce the problem.
>
> Please submit a complete bug report to [hidden email],
> including everything necessary to reproduce the problem.  See the
> section in the Octave manual on reporting bugs for more information
> about what makes a useful bug report.
>
> Thanks,
>
> jwe
>
I think I narrowed my problem (at last!) to the following:
 when I do something like

  for i=1:1000000
    eval("2;");
  endfor

everything is O.K.

But,

  for i=1:1000000
    eval("[2];");
  endfor

makes the Size bigger and bigger. Is this normal?
Shouldn't I use eval this way?

If you still need a bug-report, I will try to send you one.

Sorry for the trouble, thanks for the help.
 
Stef.


Reply | Threaded
Open this post in threaded view
|

Re: Memory....

Mario Storti-4
In reply to this post by Stef Pillaert BK-2

Hi. I reproduced the same error as reported by Stef:

> I think I narrowed my problem (at last!) to the following:
>  when I do something like
>
>   for i=1:1000000
>     eval("2;");
>   endfor
>
> everything is O.K.
>
> But,
>
>   for i=1:1000000
>     eval("[2];");
>   endfor
>
> makes the Size bigger and bigger. Is this normal?
> Shouldn't I use eval this way?
>
> If you still need a bug-report, I will try to send you one.
>
> Sorry for the trouble, thanks for the help.
>  
> Stef.

Configuration: Linux Red Hat 3.0.3 (Kernel 1.2.13) on a Pentium
i586. Octave 2.0.9 (binary downloaded from
ftp://ftp.che.wisc.edu/pub/octave).

For instance, running this:

::  octave:2> for i=1:10000
::  > eval("2;");
::  > endfor

keeps the size of the octave process low:

::  [mstorti@minerva mstorti]$ ps -alw | grep octave
::    0   502  3847  3846  13  0  793 1680 1933ef     S <  pp1   2:27 octave
                                  ^^^ ^^^^

but this:

::  octave:3> for i=1:10000
::  > eval("[2];");
::  > endfor


makes the process grow:

::  [mstorti@minerva mstorti]$ ps -alw | grep octave
::    0   502  3847  3846  28  0 1937 2836 1933ef     S <  pp1   2:43 octave
                                 ^^^^^^^^^
Mario

%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%
Mario Alberto Storti               | Fax: (54)(42) 55.09.44 |
Grupo de Tecnologia Mecanica       | Tel: (54)(42) 55.91.75 |
INTEC, Guemes 3450 - 3000 Santa Fe | Home: Gob. Vera 3161   |
Argentina                          |       (54)(42) 55.00.23|
Reply: [hidden email]  |                        |
                http://venus.unl.edu.ar/gtm-eng.html        |


Reply | Threaded
Open this post in threaded view
|

Re:Re: Memory....

John W. Eaton-6
In reply to this post by Stef Pillaert BK-2
On  2-Sep-1997, Stef Pillaert BK <[hidden email]> wrote:

| I think I narrowed my problem (at last!) to the following:
|  when I do something like
|
|   for i=1:1000000
|     eval("2;");
|   endfor
|
| everything is O.K.
|
| But,
|
|   for i=1:1000000
|     eval("[2];");
|   endfor
|
| makes the Size bigger and bigger. Is this normal?
| Shouldn't I use eval this way?

It's definitely a bug.  Please try the following patch.

Thanks,

jwe

Tue Sep  2 08:43:32 1997  John W. Eaton  <[hidden email]>

        * pt-mat.h (tree_matrix_row::preserve_expr): New private data.
        (tree_matrix_row::~tree_matrix_row): Delete list contents.
        (tree_matrix::~tree_matrix): Delete list contents.
        * pt-mat.cc (tree_matrix_row::to_return_list): Set preserve_expr
        to true if successful.


*** src/pt-mat.h~ Mon Nov 18 22:34:55 1996
--- src/pt-mat.h Tue Sep  2 08:29:04 1997
***************
*** 46,64 ****
  {
  public:
 
!   tree_matrix_row (tree_expression *e = 0) : SLList<tree_expression *> ()
      {
        if (e)
  append (e);
      }
 
!   ~tree_matrix_row (void) { }
 
    bool all_elements_are_constant (void) const;
 
    tree_return_list *to_return_list (void);
 
    void accept (tree_walker& tw);
  };
 
  class
--- 46,77 ----
  {
  public:
 
!   tree_matrix_row (tree_expression *e = 0)
!     : SLList<tree_expression *> (), preserve_expr (false)
      {
        if (e)
  append (e);
      }
 
!   ~tree_matrix_row (void)
!     {
!       if (! preserve_expr)
! while (! empty ())
!  {
!    tree_expression *e = remove_front ();
!    delete e;
!  }
!     }
 
    bool all_elements_are_constant (void) const;
 
    tree_return_list *to_return_list (void);
 
    void accept (tree_walker& tw);
+
+ private:
+
+   bool preserve_expr;
  };
 
  class
***************
*** 73,79 ****
   append (mr);
        }
 
!   ~tree_matrix (void) { }
 
    bool all_elements_are_constant (void) const;
 
--- 86,99 ----
   append (mr);
        }
 
!   ~tree_matrix (void)
!     {
!       while (! empty ())
! {
!  tree_matrix_row *mr = remove_front ();
!  delete mr;
! }
!     }
 
    bool all_elements_are_constant (void) const;
 
*** src/pt-mat.cc~ Mon Jan  6 00:13:42 1997
--- src/pt-mat.cc Tue Sep  2 08:27:54 1997
***************
*** 439,444 ****
--- 439,447 ----
  }
      }
 
+   if (retval)
+     preserve_expr = true;
+
    return retval;
  }