You can use this code to remove a path from memory. If this path has been created dynamically using path_add, the variable that holds the path index will no longer be valid for accessing the path as it no longer exists, and if the path was created using the Path Editor that path can no longer be accessed in the whole game as you are permanently deleting it.
|index||The index of the path to delete.|
t_path = path_add();
if mp_grid_path(grid, t_path, x, y, obj_Player.x, obj_Player.y, 1)
The above code will create a path and store its index in a local variable. This path is then used to store an mp_grid_path generated path which, if it succeeds in finding its way to the target, it is then assigned to the path indexed in "mypath". Finally the "t_path" is deleted.