Forums Archived

The forums are being archived. See this topic for more information.

Wait... How do I free surfaces?

Get help and support with Rubygame

Wait... How do I free surfaces?

Postby tape0 » Mon Jun 15, 2009 2:29 pm

Okay, maybe I didn't read the docs carefully enough... But how do I free a loaded surface :roll: ?
You know you are screwed when the website of the school teaching you programming is vulnerable to blasted SQL Injection.
User avatar
Posts: 6
Joined: Sun May 31, 2009 6:31 pm

Re: Wait... How do I free surfaces?

Postby jacius » Mon Jun 15, 2009 6:41 pm

In general, you just don't have to worry about freeing Surfaces (or anything else in Rubygame). The garbage collector will (eventually) automatically free them if there are no more references to them (i.e. not stored in any variables or arrays or hashes). For example:

Code: Select all
surf = Rubygame::Surface.load("image.png")
surf.blit( screen, [0,0] )
surf = nil
# The Surface will be garbage collected sometime after this.

There's not any way to explicitly free a Surface in Rubygame, although if you really need it to be freed right away, there are ways to force the garbage collector to run.
User avatar
Site Admin
Posts: 131
Joined: Fri Feb 06, 2009 11:13 pm

Return to Help & Support

Who is online

Users browsing this forum: No registered users and 1 guest