Resources Management

Resources Management is one of the strongest features of Gacela. Because Gacela is based on Lisp, we have garbage collection, but Gacela goes one step ahead, managing the memory for images and sounds. In the process of making a game, we need to allocate memory for resources as images, textures, fonts, sounds, songs, etc, and we must free all this memory at the end of the game, or at the end of the level, screen, … Gacela does all this for you.

Gacela has an internal list of resources. Each resource is saved with its properties (memory address, type, …), constructor (function to allocate the resource), destructor (function to free the memory used by the resource) and a timestamp for knowing time since the last access to the resource. When a resource is accessed Gacela updates the timestamp.

There are two types of allocating resources, depending on the timestamp. We can allocate temporary resources, using the value of the timestamp for controlling the use of the resource. When a resource has spent 50 seconds without been accessed, Gacela frees the memory using the destructor, but if the game needs the resource another time, Gacela uses the constructor for allocating it automatically.

A resource can be allocated as a static resource too. A true value t is set as a timestamp and the memory will belong to the resource while the game is running. Of course, the game can free the memory of the resource in an explicit way, using “free-resource”.

We will see Gacela’s Resources Management more in detail in future posts.

¡¡Happy Hacking!!

Advertisement
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s