Bug introduced in 9.0 and fixed in 10.0.2

Save any unsaved work before trying as it may crash Mathematica and other programs by filling up the memory!

In v9.0.1.0 on OSX 10.8.5, if I start a new session and define two functions

f1P = Sin[#^Sin[Sqrt[Gamma[#]]]] &;


f2P = Sin[#^Sin[Gamma[(# + 1)]]] &;

they both work fine. Now, if I quit the kernel and define the exact same functions but removing the ;s when I evaluate the cell with f1P:

f1P = Sin[#^Sin[Sqrt[Gamma[#]]]] &

I get some output (Sin[#^Sin[Sqrt[Gamma[#]]]] &). Then if I try to evaluate the cell with the second function definition the kernel hangs indefinitely. In fact the kernel can't handle the definition of f1P without ; at all (if I try to give it values nothing happens). Strangely, this isn't the case with f2P: I remove the semicolon, evaluate and it runs fine. But with f1P the kernel consumes more and more CPU memory. I have not idea why CPU usage spiked yesterday - I tried this today and it increased to ~35% but not more. The memory demand keeps growing though until the Kernel gets terminated or until Mathematica crashes.

This seems to be a bug with Mathematica on OSX as other people confirmed and I have now reported it to WR so I will edit again once I have confirmation from them. Still, if anyone has any idea what might be happening I'd like to know.


This issue has been resolved in version 10. WR have confirmed the bug which "causes unusual memory usage on a Mac because of the Predictive Interface"

  • $\begingroup$ No problem on my system (Windows). Seems like a very strange kind of hang. $\endgroup$ Nov 8 '13 at 16:59
  • $\begingroup$ I can reproduce what you see on OS X 10.9.0, M9.0.1. It eats up all the memory, so anyone trying this, be careful!! It hung another program on my system and I lost a document. I had to kill the remaining MathKernels by hand. I think you should report this bug. $\endgroup$
    – Szabolcs
    Nov 8 '13 at 20:04
  • $\begingroup$ Have you reported this? $\endgroup$
    – rcollyer
    Nov 9 '13 at 4:06
  • 1
    $\begingroup$ Has anyone reproduced this in a version other than 9.0.1? $\endgroup$
    – Mr.Wizard
    Nov 9 '13 at 13:40

This specific problem has indeed been resolved as of version 10.0.2, although it is still possible to run into similar behavior in other computations. The Mac failure mode is worse than on other systems.

To give an idea what was behind the system freeze, one of the operations attempted in the background by the Predictive Interface was a heuristic (based on Wolfram|Alpha code) aiming to find "interesting" plot ranges. At some point this routine was trying to solve the following ODE

NDSolve[{Derivative[1][f][x] == x^Sin[Sqrt[Gamma[x]]]*
         PolyGamma[0, x])/2 + Sin[Sqrt[Gamma[x]]]/x), f[0.00031328334725241403] == 0}, 
  f, {x, 0.00031328334725241403, -999.9996867166527}, PrecisionGoal -> 2, MaxSteps -> 1000]

On operating systems like Linux and Windows, this call would quickly fail with a General::nomem message and return


since the following intermediate number

    - 3.0631280865040788933314322086592174\
        79539626588483672`15.954589770191005*^-527458083171 I]

requires a huge amount of memory to compute -- it is a somewhat extreme example of precision coercion similar to what happens in Precision[1 - 1.*^-20000] or Precision[Cos[1.*^-10000]] and the OS refuses to allocate it.

On Mac OS X, the operating system behavior is more interesting; it actually pretends to succeed in allocating the huge chunk of memory requested by the kernel, in essence assuming unlimited amounts of virtual memory, and that is the cause of the hang.

While the underlying numerical computation issue still exists, the Predictive Interface will no longer attempt such predictions for pure function input.

  • $\begingroup$ So can we conclude that this is another hint that Mathematica does not run best on MacOSX ? I worked on Linux, Windows and sometimes on MacOSX and I find Mathematica runs best on Windows ... $\endgroup$ Sep 25 '15 at 13:37
  • $\begingroup$ No, I don't think that this example justifies such a conclusion. $\endgroup$
    – ilian
    Sep 25 '15 at 15:41

This isn't exactly an answer, but more of an observation.

I'm running V.9.0.1 on OS X 10.6.8. When I try to work with your functions f1P and f2P, I experience behavior that is somewhat different from the behavior you describe, but certainly not any more pleasant.

With a fresh kernel I can evaluate either function definition without any apparent problem. However, as soon as I try to perform another evaluation of any kind, even 2+ 2, one the two running kernels grabs every bit of available memory and continues requesting system memory indefinitely (i.e., until I kill it). This causes my system to swap memory pages out to my system hard drive and causes all running processes, not just the ones Mathematica is running, to slow down dramatically. CPU usage remains moderate.

From my experiments, I would say this is a bug and a nasty one at that.


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.