4
Needs["Utilities`CleanSlate`"]    
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*)
(*{"Utilities`CleanSlate`", "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?

dionys
  • 4,321
  • 1
  • 19
  • 46
1110101001
  • 1,979
  • 13
  • 24
  • I cannot replicate this behavior (64 bit Linux). Last line returns x for me. – VF1 May 13 '14 at 02:49
  • 3
    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 02:52
  • @Szabolcs I have the exact same setup -- even the same OS -- and it doesn't seem to work for me. Try running ClearInOut[]. That is supposed to clear all the Input and Output lines on the frontend, right? That doesn't seem to do anything for me though. Is my CleanSlate.m file broken or something? – 1110101001 May 13 '14 at 04:23
  • @Szabolcs I looked into the .m file and I think the problem might be deeper. Can you try running Unprotect["In"] and Clear[In]? That should clear all of the input lines in the frontend right? It does nothing for me... – 1110101001 May 13 '14 at 04:29
  • Interesting -- I tried this on another mac machine running mavericks (mine is running ML) with the same mathematica version and it doesn't work there either. – 1110101001 May 13 '14 at 04:37
  • 2
    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 05:42
  • 1
    @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 Yes! It works perfectly! when running without reading init.m. Come to think of it, the other machine I tested on shares the same init.m file as mine does. That is likely where the problem lies. I can post my file if you want. – 1110101001 May 13 '14 at 22:57
  • 1
    @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: http://pastebin.com/hnmUC3hG -- Why does the default work but mine not? – 1110101001 May 13 '14 at 23:12
  • 1
    @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 00:58

1 Answers1

1

I found this link that might cure this.

Click here

x:=4
x
(*4*)
Clear["Global`*"]
x
(*x*)
Bob Brooks
  • 466
  • 2
  • 13
  • 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 09 '15 at 16:13