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 authentification level.

task #7870: 0.0.2:Garbage collect old images

Submitted by:  Remco Bras <rvbras>
Submitted on:  Sat 22 Mar 2008 10:19:27 AM UTC  
 
Should Start On: Fri 21 Mar 2008 11:00:00 PM UTCShould be Finished on: Fri 21 Mar 2008 11:00:00 PM UTC
Category: C CorePriority: 7 - High
Status: Ready For TestPrivacy: Public
Percent Complete: 70%Assigned to: Remco Bras <rvbras>
Open/Closed: OpenEffort: 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>
Project AdministratorIn charge of this item.
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>
Project AdministratorIn charge of this item.
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>
Project AdministratorIn charge of this item.
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>
Project AdministratorIn charge of this item.
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>
Project AdministratorIn charge of this item.

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 26 Aug 2008 05:18:34 PM UTCrvbrasSummaryGarbage collect old images=>0.0.2:Garbage collect old images
    Mon 19 May 2008 05:18:48 PM UTCrvbrasStatusIn Progress=>Ready For Test
      Percent Complete0%=>70%
    Mon 21 Apr 2008 08:11:20 AM UTCrvbrasStatusNone=>In Progress
    Sat 22 Mar 2008 11:20:26 AM UTCrvbrasCategoryNone=>C Core
      Priority5 - Normal=>7 - High
      Assigned toNone=>rvbras

    Back to the top


    Powered by Savane 3.1-cleanup