6
$\begingroup$

This question already has an answer here:

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$

marked as duplicate by ilian, m_goldberg, MarcoB, Coolwater, José Antonio Díaz Navas May 7 '18 at 17:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ Hi, Hugh. Unfortunately for you (not for me ;) ), I cannot reproduce that with version 11.3 on macOS. $\endgroup$ – Henrik Schumacher May 2 '18 at 19:45
  • $\begingroup$ @HenrikSchumacher Thanks for trying. Happens repeatedly for me. $\endgroup$ – Hugh May 2 '18 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$ – Henrik Schumacher May 2 '18 at 19:51
  • 2
    $\begingroup$ I can reproduce this in 11.3 for Windows 7. $\endgroup$ – ulvi May 2 '18 at 20:26
  • 2
    $\begingroup$ What happens if you do $HistoryLength=0? $\endgroup$ – Carl Woll May 2 '18 at 20:39
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$
  • 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 May 2 '18 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 May 3 '18 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 May 3 '18 at 16:36

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