- From: Anselm Baird_Smith <abaird@www43.inria.fr>
- Date: Tue, 3 Dec 1996 10:23:36 +0100 (MET)
- To: Joel.Crisp@bristol.ac.uk
- Cc: www-jigsaw@w3.org
Joel Crisp writes: > > If I'm sub-classing FormResource to get a form with several cards, do I > need to lock the cards ? If I refer to other resources from those > cards, do I need to lock those resources ? If my FormResource-like > class implmements ResourceStoreHolder, do I need to lock resources > which might be stored/retrievable in the associated resource store ? > (ie. if my formCard uses a resource which can be pickled/unpickled from > my resource store do I need to lock it or can I just assume that it > will be put away and retrieved appropriately ? ) The ResourceLocker interface is meant to be implemented by objects (resources or not) that keep a pointer to any Resource. That's how the "locker" gets notified that Jigsaw is unloading a given resource (your duty is then to nullify your pointer to that resource, so that the GC can reclaim it). The ResourceStoreHolder is about the same concept, applied to ResourceStore this time. If you want to keep a pointer to a ResourceStore, then you have to implement the ResourceStoreHolder interface so that the ResourceStoreManager can get rid of that store when needed. Now, the FormResource keeps in memory all its cards. This means that all the card resources are under the control of the FormResource - they are not even pickled/unpickled. This is why even though the FormResource keeps some pointers to Resource instances, it doesn't implement the ResourceLocker. To get rid of cards, you have to get rid of the Formresource instance itself. [This is kind of tricky, I know, if you want more details, please do ask questions] > As a semi-connected aside, how long do FormResources hang around ? (and > their cards ?) Also, I notice that the editors create a new instance > for each resource edited - do I need to have a resource per user for > my IndexplusResource form thing ? The cards hang along as long as the FormResource (see above). Only once the FormResource is unloaded, will the corresponding cards disappear from memory. FormResource hang for as long as any other resources: the ResourceStoreManager is the one to decide when a given ResourceStore is to be unloaded, at what time it will pick an appropriate one to unload. All resources from that store will then be unloaded. If you want to "see" this in action, you will probably need to change: w3c.jigsaw.resources.ResourceStoreManager:getMaxEntries: protected final int getMaxEntries() { return 512 ; } 512 is the number of stores that Jigsaw will keep in memory. Lower this, to say, 8 (don't lower it more then this). Then add a finalize method to the FileResource: w3c.jigsaw.resources.FileResource { public void finalize() { System.out.println(getURL()+": unloaded !"); } } Compile, then run Jigsaw, and visit more then eight directories (by visit, I mean GET them or one of there children). Then, to have fun, get another one, things should begin to display... Anselm.
Received on Tuesday, 3 December 1996 04:23:54 UTC