Yup, I meant the likes of code that runs
after game_end.
I see a couple of things in there that will allocate new memory. I mean not just the space a new reference to a map, but actual new data. For example:
This is not a default function, so I can't know exactly what this does. Sounds like it converts data from one format to another format, though, so new data.
This will create new data, and probably have it take up more space than the original. In my experience, it roughly triples it.
If, for example, the data you're saving here takes up 250 MB in memory (largely exaggerated,
I hope) and your game resources take up 1 GB, then this single line will blow up the 250 MB usage to 1 GB. On a 32 bit runtime, this may immediately crash your game, especially if you're converting data structure data around as strings anywhere else (which, if I correctly remember your other topics, you are, or were doing at some point) because that'll explode that data's memory usage in a similar way.
Since you're using the 64 bit one, that's not the case. Total memory usage is still limited by the player's hardware, though. So even if the 2 GB limit is not a general concern, you're still blowing up the memory usage at the end of the game. I can't tell you exactly by how much, but you can measure that if you're curious to see how much of an impact it really has (if this is save data that grows in size the more people play the game, make sure to test with an endgame save file).
Alternatively, is there any other code that runs after
game_end?