taskRole Playing Game Engine - Tasks: task #7870, 0.0.2:Garbage collect old images

 
 

You are not allowed to post comments on this tracker with your current authentication level.

task #7870: 0.0.2:Garbage collect old images

Submitter:  Remco Bras <rvbras>
Submitted:  Sat 22 Mar 2008 10:19:27 AM UTC
   
 
Should Start On:  Fri 21 Mar 2008 11:00:00 PM UTC Should be Finished on:  Fri 21 Mar 2008 11:00:00 PM UTC
Category:  C Core Priority:  7 - High
Status:  Ready For Test Privacy:  Public
Assigned to:  rvbras Percent Complete:  70%
Open/Closed:  Open Effort:  0.00

Tue 26 Aug 2008 05:18:34 PM UTC, comment #4: 

Needs a specific testing app to verify proper operation, including some decent valgrinding here and there... While I'm at it, get make check to do something.

Remco Bras <rvbras>
Group administrator
Mon 19 May 2008 05:18:48 PM UTC, comment #3: 

Currently, a prototype is ready for test (actually has been for a few days). In preliminary testing, it seems to have worked, not sure if this thing is 'done' or test-ready.

Remco Bras <rvbras>
Group administrator
Thu 15 May 2008 08:25:20 AM UTC, comment #2: 

Some basic preliminary design notes:

-Every image should have a 'reference count' (type unsigned int), and a 'permanence' flag (type char).

-The reference count is used (obviously) to keep track of the amount of references made to an image. The tricky part is keeping this count correct at all times. This means that, for the lifetime of a tile, mob or other image-referencing item (a window, for instance), a reference should be kept. This reference should be destroyed afterwards. If the amount of references ever reaches 0 (on destruction of a reference), the image is destroyed (while keeping the indices of all other images in the sequence constant), unless the permanence of the image is non-zero.

-The above causes issues with things kept outside of sequences, for example tiles kept outside of tilegrids. Stale images could be kept indefinitely if tiles are not properly 'destroyed'. However, this is better than images growing stale while in use (It at least does not cause crashes).

-All users should see of this GC-ing strategy is A: that it works silently in the background (it is the duty of the API to properly handle references) and B: that they have control over the permanence flag of images.

-This latter flag exists because of use cases like the below:
A user has a tilegrid, containing a number of blue tiles, image index 0. A single tile of this grid, chosen randomly, is replaced by a red tile, image index 1. In doing so, the user re-replaces the old red tile by a blue tile.
If there is no image permanence, the image is destroyed upon destruction of the old red tile, and reallocated upon creation of the new red tile.

Remco Bras <rvbras>
Group administrator
Mon 21 Apr 2008 08:11:20 AM UTC, comment #1: 

Counting references on mobs is not particularly hard, (it should be part of the mob creation tricks), one just needs to make sure mobs are properly destroyed.

The harder part is keeping track of tiles on grids, which basically comes down to having a single reference on every image used by a tilegrid as long as it is used by that grid, while the grid keeps track of exactly how many tiles use that image (and drops its reference if the number reaches zero).

This doesn't interfere with storing tiles in GUILE space (thanks to the fact that image indices aren't ever put into SCM values), but the same problems one may have with uninterned mobs apply here. Perhaps some refactoring is needed to use indices for interned values only.

Remco Bras <rvbras>
Group administrator
Sat 22 Mar 2008 10:19:27 AM UTC, original submission:  

Images no longer used by mobs, tiles or anything should be automagically garbage collected. To do this, implement reference-counting, counting any number of occurrences in a tilegrid as a single reference.

Once this is done, test the behaviour of remove-image and the like.

Remco Bras <rvbras>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rvbras (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2008-08-26 rvbras SummaryGarbage collect old images 0.0.2:Garbage collect old images
    2008-05-19 rvbras StatusIn Progress Ready For Test
        Percent Complete0% 70%
    2008-04-21 rvbras StatusNone In Progress
    2008-03-22 rvbras CategoryNone C Core
        Priority5 - Normal 7 - High
        Assigned toNone rvbras

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code