Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: OneDollar on Fri 20/03/2009 16:06:18

Title: Deleting dynamic sprites
Post by: OneDollar on Fri 20/03/2009 16:06:18
There's a question I've been meaning to ask for a while about dynamic sprites. In the manual, under creating dynamic sprites, it says
QuoteIMPORTANT: This command loads an extra sprite into memory which is not controlled by the normal AGS sprite cache and will not be automatically disposed of. Therefore, when you are finished with the image you MUST call Delete on it to free its memory.

I know that means that if I was doing some kind of cutscene-based visual effect or using a sprite in only one room I should call the delete function on all the sprites once I'd finished with them to free up the memory they were using, but what if I want to use the sprite for the entirety of the game? Does quitting an AGS game free the memory as well or should I try to detect which sprites are in use and delete them before QuitGame() is called?
Title: Re: Deleting dynamic sprites
Post by: GarageGothic on Fri 20/03/2009 16:18:54
AGS will bitch and moan (i.e. give you an error log) if you don't delete them before quitting, but strictly speaking it shouldn't be an issue. Otherwise quitting with Alt+X or Alt+F4 would constitute a memory leak, and I've yet to experience that in AGS. I've had games with huge DynamicSprites crash on me repeatedly while testing without eating up memory after the program terminated.
Title: Re: Deleting dynamic sprites
Post by: Pumaman on Fri 20/03/2009 19:22:59
The memory will always get freed by Windows when the game exits. The reason that AGS gives you warning messages when the game shuts down and you haven't deleted some sprites is to help you out in case your script is accidentally creating more and more dynamic sprites and creating a memory leak during the game.
Title: Re: Deleting dynamic sprites
Post by: OneDollar on Fri 20/03/2009 20:15:14
Ok, thanks for clearing that up.