Thanks Martin, as I thought I was missing something, the meaning of the clear part for the Reference subclass!
Now everything is clear (as after the GarbageCollector runs!). Thanks a lot, Simone. PS Sorry for the bad joke about the GC, I could not resist! ------------------------------------------------------- Eng. Simone Giannecchini President /CEO GeoSolutions S.A.S. Via Carignoni 51 55041 Camaiore (LU) Italy phone: +39 0584983027 fax: +39 0584983027 mob: +39 333 8128928 http://www.geo-solutions.it ------------------------------------------------------- -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Martin Desruisseaux Sent: martedì 26 giugno 2007 13.00 To: [EMAIL PROTECTED] Cc: 'Geotools-Devel list' Subject: Re: [Geotools-devel] WeakCollectionCleaner doubts Hello Simine Simone Giannecchini a écrit : > I was looking yesterday at the SoftHashValueMap since I need it for > another project. I have a question regarding the WeakCollectionCleaner. > Is it really needed? All it seems to do is clearing the internal > reference of our WeakReference or SoftReference but it seems to do > nothing beyond that. The Reference objects in WeakCollection are not directly WeakReferences, but rather some WeakReference subclass that contains some additional data needed for proper working of hash map. Those references override their 'clear()' method in order to remove the entry from the hash map in addition of clearing the reference. So invoking Reference.clear() do not only clears the reference. It also removes the reference from the hash map / hash set. This is explained in WeakCollectionCleaner class javadoc, and repeated again at lines 80-81. I will move those comments closer to the call to 'ref.clear()'. We could argue that overriding Reference.clear() that way is yet an other obscure trick in my code. If the comments in the code are not suffisient for avoiding confusion, we can change that. But it would require the addition of a new private class and casting (so more class, more code, slightly less performance). > (...snip...) having a thread with priority 5 as the DEFAULT > collection cleaner doing something that we dont need to do it might be > an overkill, especially if you start putting a lot of references inside > its ReferenceQueue being them weak or soft. The thread should spend most of its time waiting. If we look at J2SE implementation, we can find many deamon threads with priority 9 or 10. Application do not suffer from such high priorities because those threads are inactive most of the time. When a thread weakup, it performs its work very quickly and go back in sleeping state very soon. Having a high priority thread ensure that this quick work is not delayed by long standing work (even if the long standing work is the actual application performing the "real" work requested by the user). This is especially important if the purpose of the quick work is to release resources. Sooner the resource are released, better it will be for application performances. It may sound like the opposite of what we want, but often the "real" work needs to be performed in a low priority thread while "system management" tasks are performed in a high priority thread, providing that the "system management" tasks are very short (and not too frequent) while the "real work" is very long. Martin ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Geotools-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-devel ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Geotools-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-devel
