6
$\begingroup$

Bug introduced in 11.2


If I put the following code in separate cells the Kernel crashes (dies). If I put them together in the same cell it works fine. Version 11.3.0 for Windows.

data = Table[{t, E^(-2 π 13.2 0.01 t) Cos[2 π 13.2 t]}, {t, 0, 40 - 1/100., 1/10000.}];
(* end of cell 1*)

ClearAll[f];
f[data_] := Module[{a, b, c},
   a = 2 data;
   b = 3 data;
   c = 4 data;
   {a, b, c}
   ];
(* end of cell 2*)

{a, b, c} = f[data];
(* end of cell 3*)

Any thoughts? Does it happen to others?

$\endgroup$
9
  • 1
    $\begingroup$ Hi, Hugh. Unfortunately for you (not for me ;) ), I cannot reproduce that with version 11.3 on macOS. $\endgroup$ Commented May 2, 2018 at 19:45
  • $\begingroup$ @HenrikSchumacher Thanks for trying. Happens repeatedly for me. $\endgroup$
    – Hugh
    Commented May 2, 2018 at 19:49
  • $\begingroup$ Sorry to hear that. It's a weird error indeed. No idea what to do apart from switching off and on again... =/ $\endgroup$ Commented May 2, 2018 at 19:51
  • 2
    $\begingroup$ I can reproduce this in 11.3 for Windows 7. $\endgroup$
    – ulvi
    Commented May 2, 2018 at 20:26
  • 2
    $\begingroup$ What happens if you do $HistoryLength=0? $\endgroup$
    – Carl Woll
    Commented May 2, 2018 at 20:39

1 Answer 1

5
$\begingroup$

The issue you are running into is that using a semicolon to suppress large output doesn't actually prevent Mathematica from storing the large output. In particular, we have the following from the documentation:

$expr_1; expr_2;$ returns value Null. If it is given as input, the resulting output will not be printed. Out[n] will nevertheless be assigned to be the value of $expr_2$.

Even though you are suppressing the output of data and {a,b,c}, their values are still being stored in Out when you put the expressions into separate cells. Apparently the storage of data causes Mathematica to exceed your available memory. The workaround is simple. Either use $HistoryLength=0, or terminate your cells with something like ; ; or ; 1;. With the latter method, Mathematica will store Null or 1 as the output of the cell, and not data.

$\endgroup$
3
  • 2
    $\begingroup$ MaxMemoryUsed[] never goes above 150MB. Even if we assume the last cell needs another 2GB of memory (surely overkill), still doesn't explain the problem in a system with 32GB RAM. $\endgroup$
    – ulvi
    Commented May 2, 2018 at 22:30
  • $\begingroup$ ulvi has added the comment that I was observing. Something else is happening or the the data memory size is being multiplied up excessively. Do you know enough to state that setting $HistoryLength=0 will solve the problem? Thanks for your help. $\endgroup$
    – Hugh
    Commented May 3, 2018 at 8:41
  • $\begingroup$ @Hugh It's not about the output size being large, but the issue can be reliably worked around by disabling the Suggestions bar. Changing the history length etc. work simply because they prevent the Suggestions bar from seeing the last result and trying to operate on it. $\endgroup$
    – ilian
    Commented May 3, 2018 at 16:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.