Saving Mathematica kernel state?

While it is true that you can not save a full state of the kernel, in some cases it may be enough for your purposes to save all symbols' definitions in some context(s), such as Global` (or whatever other contexts are of interest to you). This can be done via DumpSave, like

DumpSave["state.mx", "Global`"]

The .mx file generated by DumpSave will be platform-specific though. By using Get at some later point, you can reconstruct the values stored in symbols in those contexts you saved:

Get["state.mx"]

As stated already by @ruebenko, this will not generally fully reconstruct the kernel state. But if you manage to correctly account for all symbols (defined by you) which affect your computations, and depending on the circumstances, this may be enough for many practical purposes.


No, currently you can not save the kernel state; restarting the Kernel from a previous state would need to modify and re-instantiate all sort of things.


I have added to this question the possibility of saving the current context, storing it inside the notebook, so that it can be loaded after. It is still very rough, but I think that it can work for same cases, and give an idea for a more adapted tool.

Tags:

Persistence