Removing Realm Change Listeners


#1

On Android, should realm change listeners be removed when the parent is destroyed? Is this something that is handled by the garbage collector or will it cause a memory leak if it is not removed? Thanks for the help


#2

Hello,

Yes the practice is to remove change listeners any time the underlying data has been removed. So the practice is to call .stop() on the notification token or removeChangeListener() as shown here:

The memory footprint for a listener is small so I don’t think this would be your largest source of leakage.

Best,
Ian