How to abort or stop this (accidently large defined) SparseArray production?
s = N[SparseArray[Table[{2^i, 4} -> i, {i, 30}]]]
Alt+. or Alt+, seem to give up. Even your Windows task manager is struggling.
How to abort or stop this (accidently large defined) SparseArray production?
s = N[SparseArray[Table[{2^i, 4} -> i, {i, 30}]]]
Alt+. or Alt+, seem to give up. Even your Windows task manager is struggling.
Could use $Pre to wrap things in MemoryConstrained. I'll illustrate with an unusually tight constraint.
SetAttributes[memcon, HoldAll]
memcon[new_] := MemoryConstrained[new, 10^4]
$Pre = memcon;
Examples:
ByteCount[Range[10^6]]
(* Out[4]= $Aborted *)
s = N[SparseArray[Table[{2^i, 4} -> i, {i, 20}]]]
(* Out[5]= $Aborted *)
$Pre as I did in my earlier question this is an excellent method. I recommend it to anyone using version 7 or earlier. Belisarius gives a nice method for v8+ in the linked thread that does not tie up $Pre.
– Mr.Wizard
Jan 14 '13 at 01:14
SparseArrays that's exceeded here?
– Szabolcs
Jan 29 '13 at 22:25
InputForm[SparseArray[Table[{2^i, 4} -> i, {i, 5}]]] seems to show a dense 1-d listwith the jth element indicating how many nontrivial elements have been seen prior to row j. That at least is my guess.
– Daniel Lichtblau
Jan 29 '13 at 22:42
Evaluation->Quit Kernel -> Localoften succeeds whereAbort Evaluationfails for me. – image_doctor Jan 13 '13 at 16:42