Improving performance

Caching improves performance by storing data in RAM rather than directly to permanent storage. This allows you to combine multiple reads and writes into a single call, significantly improving performance when files contain many keys.

You can find information on caching in the Caching guide.

Reducing the number of references in the reference manager

When your scene contains an Easy Save 3 Manager, by default Easy Save automatically gathers objects in your scene and adds them to the manager so that they can be assigned a reference ID (see Saving and Loading References).

Sometimes the reference manager can contain references to objects which are no longer referenced by your scene. In this case you can press the Optimize button on the ES3ReferenceMgr Component of the Easy Save 3 Manager in your scene.

By default Easy Save also automatically adds all prefabs which have an ES3Prefab Component on them (i.e. all prefabs you have right-clicked and selected Easy Save 3 > Enable Easy Save for Prefab for). If this is not desired you can disable this by unchecking Add All Prefabs to Manager in Tools > Easy Save 3 > Settings > Editor Settings.

If you have dense scenes with a large number of dependencies (>100,000), some memory savings can be had by manually managing references to ensure that only references which are used are in the reference manager. See the Manually managing references section below for more information on this.

Removing meshes and textures from the manager

Meshes and Textures this will be added to the reference manager when you load them so that they can be assigned a reference ID. However, a GameObject’s meshes and textures aren’t destroyed when you destroy the GameObject. This also means that garbage collection won’t collect them because a reference to them will still exist.

This isn’t an issue in most cases as the reference manager is destroyed when you leave the scene, but sometimes you might want to manually destroy meshes and textures to free up memory.

The easiest and most effective way to do this is to destroy the meshes/textures using Unity’s Destroy(object) method. Alternatively you can remove the reference from the manager using the manager’s Remove(object) method. For example:

You can use Easy Save from your own thread, but you must ensure that you only use it from one thread at a time and that the data you are saving is thread-safe.

You should also ensure that you call ES3.Init() from the main thread before using Easy Save from a thread. This only needs to be done once, so can be done from a Start() or Awake() method.

However, we only recommend this as a last resort as debugging asynchronous code is extremely difficult and in most cases you can achieve a similar thing by spreading calls out using a coroutine, or use caching to sufficiently improve performance so that saving can happen in a single frame.

Manually managing references

When your scene contains an Easy Save 3 Manager, by default Easy Save automatically gathers objects in your scene and adds them to the manager so that they can be assigned a reference ID (see Saving and Loading References).

In larger scenes and projects this can become performance intensive. If you find the Editor is slowing down it’s recommended to manually manage references instead by doing the following:

  1. Go to Tools > Easy Save 3 > Settings.
  2. Uncheck Auto Update References in the Editor Settings section.

Now to add an object and it’s dependencies to the reference manager, you can right-click it and select Easy Save 3 > Add Reference(s) to Manager.

If your project hasn’t yet been released you might also want to consider deleting any Easy Save 3 Managers from your scene and re-adding them to remove any existing references. Note that this will invalidate any existing save data which uses those reference IDs, so you will also need to delete your save data.