I’m pulling your leg a little and trying to get you to explain your first assertion. So, I guess that’s basically being argumentative but for the sake of completeness. You’re pretty bad at explaining this, but I am fairly certain I get it.
The way you described it, it sounds like WeakReferences in general cause memory leaks. Not that WeakReferences can’t be relied upon to return null when the last strong reference is removed. Someone reading this might walk away thinking they cause leaks and/or not understand why this is a misuse of WeakReferences. My goal was to explain what you glossed over.
But you said: “There is no way to use a WeakReference in a way that it becomes effectively a strong reference.”
Response: o = weakReference.get(); Accessing the object you want requires creating an at least temporary strong reference. If you use a WeakReference to regularly access (in an update loop, for example) the object it refers to, then the garbage collection is going to see it was accessed and never clear the weak reference. (Effectively making it a heavy strong reference.)
I’m also not sure what circumstances would cause a weak reference to “extend the collection of the object to typically one gc cycle.” I doubt that’s correct, but it depends on whether you meant “to the end of the next gc cycle” (right, but true for most references) or “by one extra gc cycle” (wrong, as far as I know).
[quote=“Riven link=topic=27642.msg248805#msg248805 date=1351958804][quote author=Best Username Ever,post:13,topic:40000”]
On the other hand if you use weak references for much more than using a WeakHashMaps the way it’s intended to be used, then you’re basically using them as a strong reference.
Is this correct?
[/quote]
There is no way to use a WeakReference in a way that it becomes effectively a strong reference. Maybe you need to explain what ‘use for much more than their intended use’ entails.
[/quote]
I was asking about the entire post, not just the above paragraph.