Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #10932
| From | Ralph Dratman <ralph.dratman@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Quit and Restart kernel quickly? |
| Date | 2012-07-15 08:28 +0000 |
| Message-ID | <jttv06$gu2$1@smc.vnet.net> (permalink) |
| References | <20120714053229.16A18687A@smc.vnet.net> |
| Organization | Time-Warner Telecom |
Bill, As a possible supplement or alternative to CleanSlate, I use the following code near the top of a notebook: (* Limit a memory-consuming option. *) $HistoryLength = 0; (*-----*) (* The following interrupts on any message! *) messageHandler = If[Last[#], Interrupt[]] & ; Internal`AddHandler["Message", messageHandler]; (*-----*) If[True,(* Bring back in all the saved results from the fully \ evaluated file, that is, a prior evaluation of this file. *) (* The code that performs the \ save is at the bottom of this file. *) theSavedResultsFileName = StringReplace[NotebookFileName[], ".nb" -> ".mx"]; If[StringQ[FindFile[theSavedResultsFileName]], Get[theSavedResultsFileName]] ] Interrupt[];(* Pause after reloading symbols. *) Then somewhere below that, usually near the bottom of the notebook, I add: Interrupt[];(* Pause before saving symbols. *) (* The following saves ALL globals -- not necessary. *) saveName = StringReplace[NotebookFileName[], ".nb" -> ".mx"] DumpSave[saveName, "Global`"]; Saving all the globals is not always the best way to do this. Rather, replace "Global`" with a specific list of symbols whose value you want restored from the prior session. Good candidates are variables that take a long time to calculate. Ralph On Sat, Jul 14, 2012 at 1:32 AM, Bill Rowe <readnews@sbcglobal.net> wrote: > On 7/13/12 at 2:54 AM, mstankus@gmail.com wrote: > >>Is there a way to quit and restart the kernel quickly? I would like >>to do this without having to use the menu twice. > > Evaluating Quit[] will stop the kernel. Restarting the kernel > can be done by evaluating pretty much anything else. > > Note, if your purpose in quitting the kernel is to reset your > session to its initial state, take a look at the package > Utilitcries`CleanSlate`. After this package is loaded you can > evaluate CleanSlate[] to reset your session to the state that > existed at the time the CleanSlate package was loaded. > > Using CleanSlate to reset your session can be faster than > quitting and restarting the kernel particularly if you have > added several things in the init.m file the kernel executes as > it starts. Additionally, CleanSlate offers finer control on > resetting things. For example you could do > > several computations > <<Utilities`CleanSlate` > more computations > CleanSlate[] > > This would reset your session state so that variables assigned > values, functions etc created during the "several computations" > are left intact while those created during "more computations" > are removed. In contrast, quitting the kernel would remove everything.
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Quit and Restart kernel quickly? Ralph Dratman <ralph.dratman@gmail.com> - 2012-07-15 08:28 +0000
csiph-web