No MapView.removeOnTouchListener? Causes memory leak.

478
0
11-12-2018 07:29 AM
NathanMellor
Occasional Contributor

How are we supposed to remove the onTouchListener when our Activity gets destroyed?

There is a setOnTouchlistener but no remove.

Setting it to null won't work - you will throw an exception.

This is important because you are holding on to the reference and our activity can't be garbage collected, causing a huge memory leak.

We have used removeListeners for Scale and NavigationChanged.

The only thing I can think of now is to create a DummyonTouchListener that does nothing, and set it in onDestroy.

Nathan

0 Kudos
0 Replies