ds_list_destroy

This function will remove the given list data structure from memory, freeing up the resources it was using and removing all values that it contained. This function should always be used when you are finished using the DS list to prevent memory leaks that can slow down and crash your game.

NOTE Destroying a list will de-reference any data structures stored in it giving a memory leak, so you would need to go through the list and destroy all data structure items manually before destroying it to prevent this. The only time this is not required is when you have flagged any items in the list as another DS list or as a DS map, in which case these items will be destroyed and their memory cleaned up automatically as well.

NOTE You should always set the variable that held the data structure reference to -1 after calling this function, since the reference will no longer be valid.

 

Syntax:

ds_list_destroy(id);

ArgumentTypeDescription
idDS ListThe id of the data structure to remove.

 

Returns:

N/A

 

Example:

if (lives == 0)
{
    ds_list_destroy(AI_list);
    AI_list = -1;
    room_goto(rm_Menu);
}

The above code will check the value of the built-in global variable lives and if it is 0, it destroys the DS list indexed in the variable AI_list and then changes rooms.