I’ve been doing a bunch of work on dynamic procgen maps in T3. This led me to doing a bunch of before/after tests of savefile sizes to make sure nothing silly was happening (like failing to deref/garbage collect game objects that aren’t needed after a map re-roll).
The inevitable side effect of this was of course a new module: memTest github repo.
Basic usage is simple: first, create a reference save to use as the “before” size:
// Return value is true on success, nil on failure memTest.referenceSave();
Then at any later point if you want to see how much the savefile has grown by, use:
// Outputs a summary of the size difference memTest.report();
Or you can get the file size difference in bytes by calling:
// Outputs the file size difference in bytes memTest.getDifference();
getDifference() create a new save when they’re called and compare its size to the reference save’s. You can suppress this behavior by calling these methods with boolean
true as their only argument. If you do that, then you have to manually create test saves via
memTest.testSave() before using
As a side note, one of the things that the module takes care of is making sure that any game it’s compiled into a) has a player character, b) has at least one room, and c) that the player character’s
location is not
nil. Which, as it turns out, are actually requirements for creating a save state.