# Kernel inexplicably hangs if I define a pure function without suppressing output

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[#]]]] &;


and

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.

---EDIT---

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"

-
No problem on my system (Windows). Seems like a very strange kind of hang. –  Oleksandr R. Nov 8 '13 at 16:59
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. –  Szabolcs Nov 8 '13 at 20:04
Have you reported this? –  rcollyer Nov 9 '13 at 4:06
Has anyone reproduced this in a version other than 9.0.1? –  Mr.Wizard Nov 9 '13 at 13:40

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.