GMS 2 [SOLVED] - Asynchronous Buffer Saving Issues

Recently I've been trying to port my game to Xbox One though the UWP export and part of that is saving asynchronously which I've wanted to do anyways.

I followed this article whilst doing this to try and get it to work since I've never done it before and can't find anything else on it when searching:

This mostly works in the fact that it saves & loaded the file fine but for whatever reason in the Asynchronous Event, when loading it will load fine but the Event triggers another two times. To prevent a memory leak, I deleted the buffer used in this scenario meaning that when it tries again, it cannot find the buffer end crashes. Is there away to make it so that the Event only triggers once each time instead of 3 times?

This is my code in the Asynchronous Load/Save Event in a persistent object:
var ident = async_load[? "id" ];
var status = async_load[? "status"];
var error = async_load[? "error"];

if (ident == global.saveid)
    show_debug_message("saved data status " + string(status) + " error " + string(error));
else if (ident == global.loadid)
    var buffstring = buffer_read(global.loadbuff,buffer_string);
    show_message("Score: " + string(ini_read_real("Stats", "HighScore", 0)));
So the first time it runs through, it reads fine but then in the second and third, it will try to access a buffer that was deleted the first time causing the crash. I just don't get why it's running the event that only triggers when the game has finished loading 3 times

I'm probably missing something small but I can't figure it out for the life of me. If any other code is required please let me know. Thanks for reading!


Don't delete the buffer, this is handled by GameMaker automatically when it comes to async functions. It is a generally a good idea to assume bugs are due to the programmer not the program. We want to fix the bugs not work around them (unless it is in fact a program issue).

A couple things to check:
  1. Are you accidentally calling to save / load multiple times in your call? Can we see the code just to go over it?
  2. Are you checking the status when loading? Was there a problem, perhaps?
  3. Are you making sure that you are setting your global.loadid values every time and UNSETTING them afterwards? I'm not sure if GameMaker reuses IDs or not but if so then you may be catching other async events by mistake.
  4. The example you provide is using groups, is that what you are doing? Using groups would mean an async call for every item in the group.
Just throwing out some ideas here.
Last edited:
I checked all 3 and it turns out that Number 3 was the issue. I used F5 to load and F6 to save in an event and only pressed once so I knew it couldn't be that and the status would have returned an error if it failed. But I added this to the end of the code above and it worked without fail:
global.loadid = noone;
Thanks for your help! I knew it was something simple I was missing!