question

Ben Wilson avatar image
1 Like"
Ben Wilson asked Ben Wilson edited

My model won't open/my model is empty/my model crashes FlexSim - is it corrupt?

We've seen this question several times in the past. You've spent weeks working on an incredible simulation model, but the next time you open it, there is something wrong:

  • the model won't open
  • the model opens, but there is nothing in it, even though the saved file has a large file size
  • when the model opens, it displays problems such as:
    • 3D view/model layout is messed up
    • garbled text or strange characters show where they should not
    • unknown errors, warnings, and exceptions appear that did not previously (and you have already done due diligence to determine it is not simply a modeling mistake)
  • when the model opens, FlexSim crashes

In all these cases, there is a good chance that your saved model file is corrupt, and despite the software's best attempts it cannot properly read the corrupted data.

Of course you're frustrated. Weeks of work could have been lost.

So, how does this happen?

And what can be done about it?

FlexSim (other)
FlexSim (other - please specify)
Choose One
crashexceptionscorrupted modelopen model
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Ben Wilson avatar image
9 Likes"
Ben Wilson answered Ben Wilson edited

There are two main ways that a saved model file could become corrupted:

  • a general problem with your computer system or hardware, not specifically related to FlexSim
  • an error directly related to FlexSim and the model's state when last saved

Let's look at each possibility individually:

Problem with the computer system

Your computer is a complex system made of lot of parts, including electrical components, data storage mediums, and lots of software at different levels, from firmware that lives directly on devices, up through the operating system kernel, hardware drivers, and finally user-facing applications.

An error in any of those places could result in corrupted data being written, or at-rest data becoming corrupted. Data corruption can occur for many different and crazy reasons. Luckily, for a well working computer system, data corruption is relatively rare. But be careful with that attitude - all parts eventually wear out.

If corruption of your data has occurred, and it happens to have affected a FlexSim model file, then you may see some of the symptoms listed in the original question.

Model file corrupted when using FlexSim

Sometimes a model could have been "broken" while using FlexSim, and then saved in this broken state, often without the knowledge of the modeler.

FlexSim is a flexible, powerful simulation platform. Part of that power comes from having low-level access to aspects of your model, its tree structure, and underlying data.

If the data and tree structure that makes up your model is accidentally modified in a way that breaks the model, and the model is saved in that state, perhaps on top of a previously good save file, you may have inadvertently created a corrupt model file.

There are many ways your model could have been corrupted when open in FlexSim. A stray key press while in a tree view can add or delete nodes from the tree, or change the datatype of a node, or delete or add data to a node. A FlexScript script could also do the same. Perhaps you created a trigger that you thought was writing data to one part of the tree, but a wrong path actually has the script writing data somewhere else, perhaps overwriting something important. Or a script that was supposed to destroy flow items actually was accidentally coded to destroy nodes somewhere else in the tree. The possibilities are endless. There is even a chance that a bug within FlexSim is rearing its head under some special circumstance.

Corruption Mitigation

Regardless of how your model file became corrupt, there are a few standard recovery options.

  1. Sometimes the corruption only affects the model's views, meaning the underlying model itself is fine. In this case, you may be able to clear up the issue by opening FlexSim's Default Workspace. From FlexSim's main menu, choose View > Open Default Workspace:1637762933132.png
  2. FlexSim keeps your last two saves [this option removed in versions >= 22.2. learn more]. When you save a FlexSim model using Save As, it will be saved as modelname.fsm. The next time you save using simply "Save" or Ctrl-S to update the saved file, your previously saved model, modelname.fsm, is renamed to modelname.fsm!, and your new save is called modelname.fsm. In this way you always have your latest save (.fsm) and the previous save (.fsm!). If you press save twice in quick succession, you have just lost the previous .fsm! version. Don't be in the habit of pressing save several times in a row.
  3. Take advantage of FlexSim's autosave feature. By default, FlexSim will save your model every ten minutes with the suffix "_autosave". So, for our previous example, every 10 minutes there will be a modelname_autosave.fsm file updated with your most current model changes. While this will also save corruption if your model is in such a state, it's worth knowing about this file. It's very handy if you crash FlexSim while you're working on your model (infinite loop, anyone?) - you never lose more than 10 minutes of work.

    Again, this auto-saved file will also save your model if it is in a corrupted state, so it is only useful for recovering from corruption if you *know* that you just corrupted your model, and can close FlexSim and open the _autosave version. Or if your at-rest saved file was corrupted due to a hardware/system problem, it's possible that an _autosave file from your last FlexSim usage could be unaffected.

  4. It's always a good idea to save early and save often. We suggest that you save under different file nameson a daily basis. For instance, my last model from yesterday was saved as modelname20160906.fsm. Today I'm working on a new model saved as modelname20160907.fsm. In this way, even if today's model becomes corrupted and I don't realize it for a few more days, I can go back to my previous versions to find a model file that is not corrupted.

    FlexSim automates this concept using the Auto Increment Save option (Ctrl+Shift+S). This saves your model with a new filename each time you use it, by appending an underscore and a new index number to each new save. For instance, if I use Ctrl-Shift-S three times in a row, I will see modelname_1.fsm, modelname_2.fsm and modelname_3.fsm in my saved files. Here at FlexSim, some of our model builders exclusively use Ctrl-Shift-S to save their model files, ensuring that they can roll back to any previously saved model state.

  5. Backup, Backup, Backup. Versioned backups help prevent against both sorts of corruption - whether introduced during modeling or as a result of a hardware/system issue. There are many online backup solutions that keep data safe, encrypted, and backed up at offsite locations, using a small, unobtrusive program that constantly runs in the background on your computer. These are very inexpensive, even for unlimited data, on a per PC basis. CrashPlan and BackBlaze are solutions that FlexSim USA has had good experience with, but there are many other vendors in this space as well. Compared to the cost of losing days or weeks of work, this is a no-brainer. At the very least you should be running your own local backups, for many more reasons than just backing up your FlexSim models. Versioned backups are the best because they let you go back to a particular date to find a version of the file you're looking for.
  6. You may be able to load a corrupted model file into another FlexSim model in order to try to fix it, or copy portions out of it into a clean model. @Brandon Peterson has explained how to load a model file into another model as a node in this answer. If you can load your corrupted model file into a node, you may be able to save some uncorrupted portions of that model. This will not always work. Sometimes a corrupt model that cannot be opened as a model will also not be able to be loaded into a node.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Kenny Macleod avatar image Kenny Macleod commented ·

Thanks Ben

0 Likes 0 ·