CleanSlate[] not working?

Needs["UtilitiesCleanSlate"]
x:= 4
x
(*4*)

CleanSlate[]
(*During evaluation of In[4]:=   (CleanSlate) Contexts purged: {Global}*)
(*During evaluation of In[4]:=   (CleanSlate) Approximate kernel memory recovered: 0 Kb*)
(*{"UtilitiesCleanSlate", "PacletManager", "QuantityUnits", \ "WebServices", "System", "Global"}*)

x
(*4*)


When I use CleanSlate[] the variable x should be cleared from memory, right? Why does it still remain afterwards?

• Quick workaround: You can just Quit instead of using CleanSlate. CleanSlate was relevant when computers were slower and the kernel took a considerable time to start up. Using Quit was annoying at that time. Now kernel startup is fast enough that I just quit when I need a clean slate ... – Szabolcs May 13 '14 at 2:52
• I wouldn't spend too much time on this. As Szabolcs said, using Quit instead is pretty quick. It takes only a few seconds on my PC. – Sjoerd C. de Vries May 13 '14 at 5:42
• @user2612743 Try running the kernel only in command line mode, without reading the init.m file. On your Mac the command to start it would be something like /Applications/Mathematica.app/Contents/MacOS/MathKernel -noinit. Then try again. Does it work? – Szabolcs May 13 '14 at 14:28
• @Szabolcs Ok, I replaced my modified init.m file with the default one and it works fine!! For reference, here is my init.m and underneath is the deafult one: pastebin.com/hnmUC3hG -- Why does the default work but mine not? – 1110101001 May 13 '14 at 23:12
• @user2612743 Sorry, I don't have any good ideas just by looking at it. You can try removing different parts of the init.m to figure out precisely which part is causing this. (Use "binary search", remove half of it first, etc., it shouldn't take more than 3 tries.) – Szabolcs May 14 '14 at 0:58

1 Answer

I found this link that might cure this.

Click here

x:=4
x
(*4*)
Clear["Global*"]
x
(*x*)

• The Mathematica package "CleanSlate" is supposed to be more more complete than Clear["Global*"]`, in that it unloads currently loaded contexts, as mentioned by @Szabolcs in this answer. Can you please explain how or why this should solve OP's problem? – dionys Sep 9 '15 at 16:13