Testing code that uses SoftReference<T>
Posted
by bmargulies
on Stack Overflow
See other posts from Stack Overflow
or by bmargulies
Published on 2010-05-11T20:01:24Z
Indexed on
2010/05/11
20:04 UTC
Read the original article
Hit count: 246
java
|softreference
To get any code with SoftReference<T>
to be fully tested, one must come up with some way to test the 'yup, it's been nulled' case. One might more or less mock this by using a 'for-test' code path to force the reference to be null, but that won't manage the queue exactly as the GC does. I wonder if anyone out can share experience in setting up a repeatable, controlled, environment, in which the GC is, in fact, provoked into collecting and nulling?
© Stack Overflow or respective owner