Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: ClearAll ?? or what

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102792] Re: ClearAll ?? or what
  • From: dr DanW <dmaxwarren at gmail.com>
  • Date: Thu, 27 Aug 2009 06:35:38 -0400 (EDT)
  • References: <h7371j$b28$1@smc.vnet.net>

There is a utility package called CleanSlate` which does this for
you.  It was written for an older version of Mathematica, and I had
some trouble with the way it interacted with the new help system
(which resulted in multiple kernel crashes.)

To prevent the help system crashes, put the following line in your
init.m file:

DeclarePackage["Utilities`CleanSlate`",{"CleanSlate"}];

At the top of your notebooks, put the line

CleanSlate[Verbose->False];

make sure that that line is the first thing to execute on a fresh
kernel start.

Functionally, what happens is this: when the CleanSlate` package is
loaded, the state of the memory is marked.  On subsequent calls to
CleanSlate[], the state of the memory is rewound to the marked state.
So if you execute anything before loading CleanSlate`, say x=3, then x
will not be reset when you call CleanSlate[] the next time.

The crashing problem occurred because I was autoloading CleanSlate` in
my init.m.  Traditionally, your personal init.m file is supposed to be
the last thing executed upon a clean kernel start, but it turns out
that some of the paclets, including the paclet for Documentation
Center, get loaded after your init.m.  This meant that my first call
to CleanSlate[] also wiped the state of the memory for Documentation
Center, and everything crashed horribly.

By declaring the CleanSlate` package in my init.m file, I make the
kernel aware of the CleanSlate` context without loading the file until
my first call to CleanSlate[].  I put CleanSlate[] at the top of every
notebook and make sure it is the first thing executed.  As I work, I
occasionally do a Control-s (save), Control-a (select all), and Shift-
Enter to clean out my memory from the shrapnel I left around while
figuring out how to do something.  I like a clean memory space.

If anybody has another way to clean out the memory please post your
methods.  I am concerned about the longevity of CleanSlate` and
whether it will be around or not in a future version of Mathematica.
I do not know how it interacts with dynamic evaluation, and I have
gotten occasional error messages in notebooks with dynamic content.

Hope this helps.  Please send me a direct email about your book and
when it will be published.

Regards,
Daniel


  • Prev by Date: Re: Viewing packages in mathematica
  • Next by Date: Re: DynamicModule causing problems with Manipulate setter bar
  • Previous by thread: Re: ClearAll ?? or what
  • Next by thread: Re: ClearAll ?? or what