caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Weak hashtables & aggressive caching
@ 2006-08-14 14:58 Matt Gushee
  2006-08-14 15:47 ` [Caml-list] " Richard Jones
  2006-08-14 21:23 ` Jacques Garrigue
  0 siblings, 2 replies; 12+ messages in thread
From: Matt Gushee @ 2006-08-14 14:58 UTC (permalink / raw)
  To: caml-list

Hello, all--

I wrote a LablGTK-based image viewer this past weekend; one of its 
features is an image cache--specifically, a weak hashtable that contains
values of type string * GdkPixbuf.pixbuf (the string being the file 
name). When a particular image file is requested, it is retrieved from 
the cache if it exists there; otherwise it is loaded from disk (and 
placed in the cache at the same time). This is useful if the user wants 
to quickly look back through a series of images that have already been 
loaded, but it doesn't help with loading images for the first time.

It seems to me it might be useful to implement an aggressive caching 
strategy--i.e., since the files to be loaded are known in advance (from 
the command line), there could be a low-priority thread that would look 
ahead and load images before the user requests them. Of course, if too 
many images are loaded it might trigger the garbage collector, which 
would defeat the whole purpose. Ideally, preloading should stop somewhat 
before garbage collection starts.

 From the documentation, it appears that the GC.stat and GC.control 
functions could be used to regulate the caching behavior, but I have not 
worked with the GC module before. Has anyone done something like this? 
Is it worth the effort? Any non-obvious pitfalls I should be aware of?

-- 
Matt Gushee
: Bantam - lightweight file manager : matt.gushee.net/software/bantam/ :
: RASCL's A Simple Configuration Language :     matt.gushee.net/rascl/ :


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-08-16  4:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-14 14:58 Weak hashtables & aggressive caching Matt Gushee
2006-08-14 15:47 ` [Caml-list] " Richard Jones
2006-08-14 16:28   ` Matt Gushee
     [not found]     ` <44E0A8F1.8060504@janestcapital.com>
2006-08-14 17:35       ` Matt Gushee
2006-08-14 18:18     ` Richard Jones
2006-08-14 23:25       ` Matt Gushee
2006-08-14 21:23 ` Jacques Garrigue
2006-08-14 23:30   ` Matt Gushee
2006-08-16  0:54     ` Jacques Garrigue
2006-08-16  4:33       ` Matt Gushee
2006-08-15  4:55   ` skaller
2006-08-15 16:17     ` Matt Gushee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).