MZ "Save data is too big" in Console

Hi everyone,

I just noticed the warning "Save data is too big" in the Console log.

It mainly happens during autosaving. I deactivated the Autosave and placed manual saving points in events for autosaving in specific situations.

From my understanding, the savegame contains the code of the current event, to continue processing, e.g. in a middle of an autostart event. So, I see the reason for being bigger and smaller from time to time.

When I first noticed, the savegame was 222 kb in size. It was in fact weird, as the file didn't contain the typical "èä^.§W×ëyZ[`gùEñÍú" stuff, but Asian language. Still gibberish, but it seemed like an unfinished process.
But I was able to load it, and it seemed fine at first glance ...

I replaced the Autosave location into a seperate event, so there's less data to store. The savegame is ~75 kb now, but the message "Save data is too big" still shows up.

My question is - what size is actually "too big"?
I don't think I can ignore this message, even if the savegame can be loaded, as I can't tell for sure if some data is cut off.

Do you have any insights on this topic?

Thank you!
The most likely cause of such an error is not any single event (that would have to be extremely long to cause this), but one or more plugins adding their data to your sevefile - most likely a plugin for dynamically adding to the database like clone actor or item variance or something like that.

you would have to post screenhots of your plugin manager to check if that is the cause or not.
The difference between 75 and 222kb is close to certainly my evented custom battle system. At the very end it will teleport you back to the village if you lost, and that would call an autosave. I expect the call into call into call to be one big event, that will be stored as 150kb extra.
The autosave now appears outside of that block, hence the smaller savegame size.

Still, the message appears.
It's tough to find any info on that, as I'm not quite sure what to look for exactly. I got some suggestion, that it might not refer to the actual save file size, but the localStorage limit, which only matters if the game runs in a browser.

Plugin list:

1753553984704.png
The engine itself does not cut any data, it just shows a warning if the final data, after compression, is at least 50000 UTF-16 characters, i.e. 100000 bytes. Like you mention, I think this is only really a concern for web games, due to their limited local storage allocation. 👋

The unexpected size of your saves might be partly due to:
  1. Saving in the middle of a BIG event, like you mention. You might mitigate that by breaking parts of it off into common events and/or separate event pages.

  2. Galv_EventSpawnerMZ - if the spawned events persist after leaving their map, that could lead to a gradual increase in save data size over the course of a playthrough. Especially if you forget to despawn/delete such an event once you're done with it.

  3. EliMZ_MapReveal - if you have many large maps, this might become significant for longer playthroughs. I'd expect the plugin to just store something like an array of true/false values, though, which should compress very well.
Spoiler: more technical info
MZ converts save data to a JSON string, then zips it using the DEFLATE algorithm (lossless compression) to further reduce the file size. The actual ratio of input to output data size depends on the data itself, e.g. highly repetitive data will compress more readily.

DEFLATE works on data of arbitrary length, so I assume the only practical limit is the length of a string in JS, which if playing it safe seems to be ~512 MB (source). If your save data were to grow that big then that would certainly be a problem! 😅
Thank you for the explanation! I feel more confident now in leaving it as is, since I don't plan a mobile or browser release anyway. But it's good to be aware of this and do tweaks like excluding the autosave from the battle system itself.

The EventSpawner and MapReveal are used for a single map each, so they should be fine.
(that would have to be extremely long to cause this),
I can say with confidence that a 5,000 line event doesn't have a noticable impact on much by itself.
Here is the code responsible:
JavaScript:
StorageManager.jsonToZip = function(json) {
    return new Promise((resolve, reject) => {
        try {
            const zip = pako.deflate(json, { to: "string", level: 1 });
            if (zip.length >= 50000) {
                console.warn("Save data is too big.");
            }
            resolve(zip);
        } catch (e) {
            reject(e);
        }
    });
};
I suppose you could change the condition for the zip length to be >= 100000 or just remove the warning all together if it bothers you. No one else will see the warning unless they can run the console during gameplay.

Original thread: https://forums.rpgmakerweb.com/threads/save-data-is-too-big-in-console.179175/