Saving world in a safer way

While playing CDDA on a low-RAM device (2GB total of which 1.5GB was free for CDDA to use) it started lagging so I decided to save and restart. Mid-save (at something like 14k/38k map chunks) device ran out of RAM completely and froze. I rebooted it but upon loading discovered that the slightly modded Humvee I was driving disappeared from under my character setting me back severely. At least the world is loadable, even if some stuff is missing or doubled (some stuff I already looted between the saves was back in its place and in my backpack).

Can saving be done safer? Akin to how filesystems change files, write a save to a completely new directory then rename the directories appropriately. Or something of the sort. If saving uses some optimizations to speed up the process of writing to the already existing world perhaps keeping two folders and simply changing a single link pointing at the latest one would suffice, making the speed about the same while only taking up twice the disk space. Or, I dunno, use Git as internal DB for saves.

I can’t speak to the ways saving could be improved on the backend, but one thing you personally could try is to increase the frequency of autosave. That way there is less data to be written each time you save and less data to be carried in memory waiting to be saved.

Out of curiosity, what kind of setup do you have in terms of hardware and operating system? Might be worth it to add a quicker thumbdrive as swap space or something if that is applicable.

If your conputer runs out of RAM mid save, you’re hosed. The best you can hope for is the save failing entirely and rolling back to the previous save, in which case you might as well do save backups yourself. Did I mention you should back up your saves? You should back up your saves