I finally understood what weak references are for:
http://weblogs.java.net/blog/enicholas/archive/2006/05/understanding_w.html
Simply put, the referenced object (by one of the reference classes) can be claimed by the garbage collector at any time, and you wouldn`t have that object anymore. Why the hell would I want to use that, then?
The answer is simply: caching.
By doing some hack around the class SoftReference, you could have a caching mechanism that would delete objects from the cache when the Java VM needs more memory. Instead of crashing, you would lose some objects from the cache, which would have to be obtained later, but no big deal - that`s just a small performance penalty.
I would like to have that knowledge 5 years ago. It would have been useful.
This is my blog in English, about the stuff I do for a living, and about the stuff I read about the stuff I do for a living - when I am not working.
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2009
(12)
-
▼
March
(10)
- I learned a new thing today...
- 8 rules to discourage your employees
- LINQ
- Interesting stuff...
- Why does Google messes up with my iGoogle page?
- Stack Overflow and the human developers
- I am leaving, I am leaving
- Maven with Eclipse, not anymore...
- Eclipse for software development...
- This is going to be...
-
▼
March
(10)
No comments:
Post a Comment