Improving performance

Caching improves performance by storing data in memory. This allows you to read and write multiple keys while only accessing the file once, significantly improving performance when files contain many keys.

Creating a file in the cache

You can create a file in cache by simply setting the storage location to ES3.Location.Cache:

Storing a cached file to a local file

You can store a file in the cache to a permanent local file using ES3.StoreCachedFile.

Loading an existing file into the cache

You can load an existing file into the cache using ES3.CacheFile. You can then read data from this cached file by settings the storage location to cache:

The ES3.CacheFile method can also accept a filePath if you wish to cache a specific file rather than the default file:

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.

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.

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.