Wouldn't it be the responsibility of the Factory to worry about releasing objects to the GC?So the instance, and it's string, can still be GC'd, right? Nope.There is still a live reference to each OtherObject instance sitting in the static HashMap "cache". Therefore, this instance cannot be GC'd, even though *you* have released your own reference to it. And, if the OtherObject class is loaded from Tomcat's common/lib directory (for example), there is no way to ***ever*** GC this instance, because the public API of the OtherObject class doesn't offer any way to clear the cache.
I mean, if it implements caching, it should have some sort of policy when an instantiated (and, thus, cached) object is a candidate for GC. Obvious guidelines are:
- if it is not used
- if it has last been used less recently than some limit
One can also think of a non-linear function, which checks the available memory or has it's internal memory limit.
Nix.
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>