ImageCache class
Kai-Uwe Behrmann
ku.b at gmx.de
Sun Aug 24 21:55:41 BST 2003
Am 23.08.03, 10:19 +0200 schrieb Pablo d'Angelo:
> therefore the ImageCache class should check how much memory it consumes
> and then remove pictures from the cache, depending how much RAM is still
> available. I will probably use a simple "remove the olded" strategy.
The idea with releasing unneeded memory is great.
Why would You prefere to unload the picture and not let it stay in swap
space? The difference would be (IMO) to unpack the one and reread from
swap space the other. In the best situation this would bring no time
savings. (I expect swap space on disk is no problem at all.)
> This check could be done on every image request to image cache.
> We just need to guarantee that we do not delete pictures that are still
> in use by other classes. Therefore the image cache needs a reference
> count that tells if the image is still in use.
>
> A while ago I tried to implement a reference counting with proxy
> objects, but it became quite messy.
Does this mean, every funtion has to tell when it internally dont need
this picture anymore or is this somewhat automatic ?
> Kai-Uwe, do you keep the wxImage* returned by ImageCache? If
The functions use the image only once and ask again to ImageCache for an
new pointer to the image.
> there are places that need them across multiple functions then I would
> have to implement the reference counting.
>
> Otherwise I can skip this issue and just remove pics from the cache :)
This should work.
Mostly the gui needs some attributes of the image to rebuilt the table
list again. At the moment I ask allways the wxImage directly for height
and name ... The only which really needs the whole wxImage is the
controlpoint editor. I suggest to store the attributes in ImageCache so
the gui can read it without the need to reload the whole thing. I would
like to help switching all list funtions and so on ;-)
As long as the "*_small" image remains in the cache for thumbnails, this
should work. The functions, nedded by the gui, could be called
getHeight(), getWidth(), getName(), getCount() .
The gui makes no use of exif data after the first loading. If You plan to
reload exif data later, please store them as well separetly without
erasing.
Kai-Uwe
More information about the ptX
mailing list