Re: System.gc not enqueuing cleared WeakReferences
- From: Thomas Hawtin <usenet@xxxxxxxxxxxxxxxxx>
- Date: Wed, 18 Jan 2006 23:16:21 +0000
Ian Pilcher wrote:
I have (finally!) reached the point of writing unit tests for my WeakIdentityHashMap, and testing for proper removal of otherwise unreachable keys is proving to be quite a problem.
Currently, my tests assume that a call to System.gc() will ensure that all cleared WeakReferences will be enqueued, but this does not appear to be the case.
Does this sound credible? (This is Sun's 1.5.0_06 JVM on Linux, BTW.)
References are not guaranteed to be enqueued immediately after they are cleared. In Sun's implementation all references get passed through a maximum priority thread before becoming enqueued. A further complication with UNIX threading is that, unless the process is run as root, the thread priority is apparently ignored.
If System.gc() won't do the trick, does anyone know of anyway to ensure that all WeakReferences are actually enqueued?
I have a suspicion that References objects that are dropped themselves or only referenceable via WeakReferences do not get enqueued. That was on my list of things to check...
Tom Hawtin -- Unemployed English Java programmer http://jroller.com/page/tackline/ .
- Follow-Ups:
- Re: System.gc not enqueuing cleared WeakReferences
- From: Ian Pilcher
- Re: System.gc not enqueuing cleared WeakReferences
- References:
- System.gc not enqueuing cleared WeakReferences
- From: Ian Pilcher
- System.gc not enqueuing cleared WeakReferences
- Prev by Date: using System properties in application vs. Singleton class?
- Next by Date: Re: What percent of Java developers use Eclipse?
- Previous by thread: System.gc not enqueuing cleared WeakReferences
- Next by thread: Re: System.gc not enqueuing cleared WeakReferences
- Index(es):