I'm running Mathematica 12.1.1 on my Windows 10 laptop (Dell Latitude E5550 with Intel iCore 5, 8 GB RAM). My MMA sessions tend to be very long, sometimes extending on over days and weeks, interrupted by hibernation and wakeup. I develop software that uses a lot of graphical output such as ArrayPlot[] of matrices size 300x300 or so.

The stability is good, but the MMA Frontend always slows down over time. In heavy use, the slowdown becomes already noticeable within a single working day, i.e., before I hibernate the laptop at the end of the working day. The slowdown is most obvious when editing or typing commands and I sometimes reach the point that it takes the Frontend a second or so to display character after character when quickly typing a new command or line in a Module[]. Quitting and restarting MMA is then the only option (ClearAll["`*"] or even Quit[] and kernel restart doesn't help), but it takes me about 10 minutes to reload all notebooks and definitions and resume work, hence I'm hesitant to do so too often.

I usually have about 10 to 15 notebooks open, but normally I either save and close notebooks with lots of figure output, or else overwrite them on each rerun of the code I'm testing. I monitor the Frontend and Kernel memory which both keep climbing steadily, but not to the point that they consume more than 1 GB or so, hence just a small fraction of my total RAM. I already set $HistoryLength=150 to prevent the command history from accumulating.

Can anybody tell me what's the reason of the slowdown (memory leaks, excessive number of variables to look up in the automatic variable suggestion/completion function, stale file handles, memory page faults, or a bug in the Frontend....)? Any suggestions how to better monitor my session or find/remove the root cause of the slowdown?

Thanks, Ron

  • 1
    $\begingroup$ Maybe the answer is this ;) $\endgroup$ – Henrik Schumacher Dec 21 '20 at 14:47
  • 1
    $\begingroup$ How about setting $HistoryLength=0 for starters. $\endgroup$ – Dominic Dec 29 '20 at 14:29
  • 1
    $\begingroup$ Related/duplicate: mathematica.stackexchange.com/questions/216746/… $\endgroup$ – Michael E2 Dec 29 '20 at 17:49
  • $\begingroup$ Hi Michel, I don't think this post is very much related, or even a duplicate. The post you linked above reports an issue when using datasets with MMA version 12.1.0. I'm using 12.1.1 and no datasets. $\endgroup$ – RonH Jan 2 at 16:37
  • $\begingroup$ I have experienced this too (Windows 10) and it is not related to $HistoryLength. I even opened a LinkSnooper kernel to see if some dynamic content was creating too much traffic but didn't find this to be the case. In one of the Live CEO streams I asked about having a performance benchmark for the frontend and SW liked the idea but it is not in the pipeline. I have to restart the Mathematica front end from time to time to avoid the very slow performance. $\endgroup$ – Gustavo Delfino Mar 26 at 13:49

By default Mathematica uses $HistoryLength = Infinity, so it stores every output expression since you started Mathematica in the data associated with the System symbol Out. If a lot of your output takes a lot of memory, you can easily slow down your computer. Instead, you could use this

$HistoryLength = 2;

Then Mathematica will only remember the two most recent output expressions (but that would not apply to anything you did before $HistoryLength was changed). Better yet, run the following once, and Mathematica will do that every time it starts!

InitializationValue[$Initialization] = Hold[$HistoryLength = 2]
  • $\begingroup$ ... or you could just chuck $HistoryLength = 2 into init.m... $\endgroup$ – J. M.'s torpor Dec 29 '20 at 13:12
  • 1
    $\begingroup$ Thanks J.M., but as said in my post, I already tried limiting $HistoryLength without success. Even restarting the kernel doesn't help, so I think it's a FrontEnd problem. $\endgroup$ – RonH Dec 31 '20 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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