Sys.save() don't work with big tables?

We have a large table for localization. it is perfectly loaded and encoded. when we try to save it in the cache for optimization, we get the error:

ERROR:SCRIPT: /modules/common/JsonData.lua:61: buffer (459 bytes) too small for table, exceeded at ‘task_2_count’ for element #16
stack traceback:
[C]: in function ‘save’

If we reduce the size of the table, the error disappears.
The question is - are there any restrictions on the size of tables in the function sys.save () ?

P.S. i attach table if you want to reproduce quests.zip (31.1 KB)

Yes, there is a limit. See https://www.defold.com/ref/sys/#sys.save

@Mathias_Westerdahl noticed that the file buffer size is set to 512kb, not 128kb. So the docs are wrong. I’ll fix that.

1 Like

Would it be possible to make a version of the function with a custom buffer size?

Technically, I suppose we could add support for arbitrarily big files. But there is a drawback in that you will experience hitches with large files since the save packing and unpacking happen on the main thread.

1 Like

Make a version which can also async on its own thread too?

If users are saving large files only on screen transitions it might be okay and better to have the option than not.

1 Like

Yes, as example we save our big tables in cache on the loading screen.

You could use json encoding for the table and normal io.* functions to load and save.

4 Likes