# Q: How to manage notebook crashes, “In a previous session”, and memory consumption?

I worked in a notebook. Something went wrong. I do not know what or why. The notebook did not react anymore and closed.

After it, I try to open the same notebook. Then the next text appears:

"The file you are opening appears to have been edited outside of the Wolfram System. The file outline cache was ignored. This should not affect any of the contents of the file."

For your information: The notebook is not opened in another system. As far as I know.

After I opened the notebook many cells with code disapeared. Most cells shows the next text: 'in a previous session'.

Has anybody experience with this? And is there a way to read my script/code?

So, there are a couple questions here, I'll answer both to the best of my knowledge. I'll hopefully provide a successful edit to your question after I submit this, also. I am commenting on my mobile, but I will provide some self-contained functions later today, as it will be helpful to see some various methods laid out.

Let me begin by stating that if you do not have any unsuppressed output of your data (having been saved in a previous session that did not end in a crash) or exported wdx (or similar format) versions of your files in question, you will not be able to recover them from the crashed session. I've lost half days of calculations to this, and even my exports were unrecoverable, or blatantly in error, it happens, it is not ideal nor intended, and is entirely preventable through some clever programming paradigms I probably don't understand as well as they deserve.

I regularly have this indication appear when opening a notebook I have worked in during a previous setting, so the label is not unknown, or appearing in error. However, I also regularly have been creating the above referenced outputs wherein I overload my RAM cache, and cause my kernels to crash, and this error appears there also. So, there is some experience there, and it has led to some workaround solutions.

To solve this, I implemented a few levels of (what I call) set and data segmentation. What I mean by this is that you should take care to output your data in smaller memoized sets, and then construct larger sets from references to the indexes/locations of the smaller sets. If you will not export your large datasets as detailed below, you should not evaluate or output the collated dataset until the latest point in time in your MMA session, module, program, package, etc. This prevents an inflation of your memory consumption.

Through this method, I was able to perform large 3D plotting of tensors with dimensions of 100-300+. Something like {100,300,300,300} if I remember correctly.

BUT ALAS! I would close my notebook after saving and even exporting the figures, but the data would be gone from the cache, and exporting such large data sets caused crashes due to the duplication of the massive dataset.

AND SO, the solution came to Export[] each of the smaller datasets, of {100,300,300}, for example, and import them in after, having (admittedly unintentionally) made a master-dataset during the segmented export filled with the index/location references with which I performed the segmented import.

Of course, you have to do some rearranging of your dataset after all of the segmented exports and imports. But, presuming you are dealing with large enough collated sets, it will prove to be useful to learn to properly navigate and manipulate your outputs, so you are not accessing the entire file size each time you interact with it.

I hope this provides some insight! I presume it may be written a bit wonky in places, and this represents my general method of understanding of things (wonky). Please let me know what I can clarify, if anything, and if there is particular (expedited) interest in the segmented methods.