[Top][All Lists]

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

memory exhausted

From: John W. Eaton
Subject: memory exhausted
Date: Wed, 29 Jul 1998 13:53:46 -0500 (CDT)

On 28-Jul-1998, A. Scottedward Hodel <address@hidden> wrote:

| I ran the following code on 1 172x172 matrix:
| # truncate acd to 6 digits of precision...
| for ii=1:rows(acd)
|   for jj = 1:columns(acd)
|     eval(["acd(ii,jj) = ",sprintf("%12.6E",acd(ii,jj));]);
|   endfor
| endfor
| After some time into the loop, Octave repeatedly
| displays an error message:
|     "memory exhausted --- trying to return to prompt"

As other people have noted, there may be more efficient ways to do the
above operation.  My comments are only about the memory problems.

The trouble is that for each element of the matrix acd, the statement

  eval(["acd(ii,jj) = ",sprintf("%12.6E",acd(ii,jj));]);

will cause Octave to evaluate something like

  acd(ii,jj) = 5.746209E-01

which also results in Octave printing the entire matrix.  Unless
paging is turned off or immediate paging is enabled, Octave will
buffer all the output before displaying it.  Using the default output
format for a 172x172 matrix requires about 350 kilobytes of storage.
Since the entire matrix is displayed for each assignment (172x172 of
them), the total storage required for buffering is approximately
10354400 kilobytes, or about 9.87 gigabytes!

There are a couple of ways to keep Octave's eval statement from
printing the result.  One is to end the string to be evaluated with a

  eval(["acd(ii,jj) = ",sprintf("%12.6E;",acd(ii,jj));]);

Another is to set the built-in variable `default_eval_print_flag' to 0.

Also, I would write the eval statement this way:

  eval (sprintf ("acd(ii,jj) = %12.6E;", acd(ii,jj)));

which should be slightly faster as it eliminates the relatively
expensive string concatenation inside the square brackets.


reply via email to

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