• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

 Garbage Collection in Studio (split from subscription topic)

gnysek

Member
Eh, not really.
GM can be a very 'difficult' language because it is simple.
The lack of GC, and such can lead to problems other languages avoid.
But gc for structures is coming. For sprites and sounds it probably never can, as when switching rooms you would loose all that data (of course it can be assigned to global.variable, but that might be too much for novices, when they still have problem to move score between rooms, or use variable as flags to remember that something was done or not yet).
 

GMWolf

aka fel666
But gc for structures is coming.
Source? seems like it would be very hard to do since Data structures are indexed and dont have a type.

Truly, GML is not an easy language. Its easy to make mistakes with it. Its just very simple, and thus quick to learn.
 

gnysek

Member
You need to search trough Mike or Russell posts. Data structures won't be indexed, but this is probably coming in GMS2.1, so may be not this year, as they already have a lot of other things coming.
 

FrostyCat

Redemption Seeker
You need to search trough Mike or Russell posts. Data structures won't be indexed, but this is probably coming in GMS2.1, so may be not this year, as they already have a lot of other things coming.
Where's the source for this? I've only seen Mike and Russell talk about type metadata in data structures, availing them to garbage collection weren't evident in what they said thus far. It would be great if they can, though.
 

GMWolf

aka fel666
Where's the source for this? I've only seen Mike and Russell talk about type metadata in data structures, availing them to garbage collection weren't evident in what they said thus far. It would be great if they can, though.
I don't know if GC makes much sense right now without GML getting major changes first.
 

gnysek

Member
@FrostyCat - I've got some time now to search today, so here it is:

https://forum.yoyogames.com/index.php?threads/asset-properties-proposal.13394/#post-88032

We are heading towards this type of syntax but it is going to take a while as the internals change to prepare the way... so no definitive time frame (depends how much time I get to work on it)

The first step towards this is making the data structures and resource types into reference values and not index numbers (as they are just now)

Russell
It was even reply to my topic in fact, I forgot already :p
 

gnysek

Member
@Fel666 They don't need to mention GC, as all referenced things are automatically removed from memory, when reference is deleted. As for now, game maker does this for variables which keeps real, string or array. Also does it for sub ds_map/list if you delete JSON loaded ds_map (or subelements were marked by you manually), and deletes ds_maps used by special events (async/gestures). Other resources, which (and if) were linked by those values are still kept in memory.
 

GMWolf

aka fel666
As for now, game maker does this for variables which keeps real, string or array
There is a difference between freeing a variable and freeing the memory that variable refers to.
Right now, only arrays are garbage collected.
 

gnysek

Member
No, some ds_structures too :)

GameMaker Studio 2 creates the necessary ds_maps and lists from the JSON, and for cleaning up you only need to delete the top level map or list and GameMaker Studio 2 will automatically delete from memory all the maps and lists underneath.
- isn't removing only top level of that kind of structure a GC ? This doesn't work for all DS structures, only those made by json_decode, but it works.
 

GMWolf

aka fel666
No, some ds_structures too :)

- isn't removing only top level of that kind of structure a GC ? This doesn't work for all DS structures, only those made by json_decode, but it works.
Yeah, but it still isnt garbage collection
That's just cascading the destroy.

Garbage collection would be going through the structures, checking how many references to it exist. Freeing it if none exist.

Here, we could have more references to a json DS, but it will still get freed of you free the top level DS.
 

babyjeans

Member
Garbage Collection primarily differs in that you can 'lose' references to objects loosely, and it will still free the memory.
i.e., if I were to do something like:

var newMap = ds_map_create();
newMap = ds_map_create();

the first created map no longer has a reference to it, normally this is just lost and a leak - with garbage collection, it'd automatically discover the reference is lost, and free its memory.

That's the kind of behavior @Fel666 is referring to.
 
Top