Deleting dynamic sprites

Started by OneDollar, Fri 20/03/2009 16:06:18

Previous topic - Next topic

OneDollar

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?

GarageGothic

#1
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.

Pumaman

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.

OneDollar

Ok, thanks for clearing that up.

SMF spam blocked by CleanTalk