Bug introduced in 9.0 and fixed in 9.0.1
In Mathematica 9, if I display any large SparseArray
object in the default way (which looks something like SparseArray[<97293>, {25000, 25000}]
), the MathKernel process will keep using 100% CPU, the Front End will hang and eventually display the "Kernel is not responding to a dynamic evaluation; Abort or Continue waiting?" dialog. Pressing Abort will kill the kernel process.
I am looking for a way to avoid / work around this.
Reproducing the problem
Try
g = RandomGraph[{25000, 50000}];
AdjacencyMatrix[g] (* note missing semicolon *)
In a few seconds after the result is displayed Mathematica 9 will hang in the sense that:
- the beachball cursor shows intermittently (on OS X)
- the kernel uses 100% CPU (one core)
- subsequent evaluations will be impossible until the kernel is killed
Mathematica 8 will not hang.
Observations
Not displaying the SparseArray (putting a semicolon after
AdjacencyMatrix[g];
) avoid the problem.The displayed form of the SparseArray is very short. This is true even for the cell expression. The problem is not caused by an overwhelming amount of data being sent to the front end.
I still want to keep track of how many non-zero elements there are in the SparseArray so I would like to display it
Disabling Dynamic updating from the Evaluation menu does not change anything. That would have been a usable temporary workaround.
The problem does not appear when using the command line version (kernel only) of Mathematica
Killing the kernel manually (not using the front end) causes
INTERNAL SELF-TEST ERROR: Kernels|c|6568
I believe this to be a bug and I'll contact support, but some analysis of why the problem happens would be useful to work around it. Or perhaps just a way to find the number of non-zero elements quickly. Then maybe I could write an alternate Format
for SparseArray
objects.
Version & system info
This happens with Mathematica 9.0.0.0 on OS X 10.8.2, 16 GB RAM. Can someone on OS X try to reproduce the problem?