Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
__weak и __strong
@property ( strong ) ...
@property ( weak ) ...
private final Reference<Object> ref;
private final WeakReference<Object> ref;
The problem is that the runtime doesn't have enough information on which references to clear and which to keep. Most importantly, the runtime doesn't know what to do when given the choice between clearing a soft reference and growing the heap. You may disagree with Dalvik's policy, but by using soft references you've elected to not be involved in that decision.
Your Android device is not like «regular Java». «Regular Java» applications typically run all by themselves on big machines with plenty of RAM and virtual memory. It's okay for «regular Java» to keep soft references around a long time; for them memory is cheap.
The device in your pocket runs more applications simultaneously using less memory. If Dalvik were to retain more soft references, then the OS would have fewer cached processes and the latency to switch between apps would be greater. The memory needs to come from somewhere.
Слабые ссылки в различных языках программирования