when to use weak pointer (wp) in android native framework (AOSP) -


i know different between sp & wp, , sp automatically recollect dynamically allocated memory. not know when , how wp used? can give me example? thx~

you must know using sp increase ref count of object, while using wp won't. wp store of address, cannot used access fields of object, unless promote it. if object released, wp.promote() return null pointer.

so, wp used in scenarios want have reference cache of memory object not want hold it. access data promote wp every time, , if object not available more, need (ask other code to) create again.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -