osmdroid: Sample application, memory leaks found by LeakCanary

Issue Type

[ X] Bug

Description and/or steps/code to reproduce the problem

I was using the demo application and noticed that LinearLayout is leaked when calling a sample and moving back to the ListView. I added screenshots from three different cases below.

Environment

If it’s a bug, version(s) of android this affects:

All

Version of osmdroid the issue relates to:

6.1.5

Screenshot_20191227-105837 Screenshot_20191227-105847 Screenshot_20191227-105909

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (5 by maintainers)

Commits related to this issue

Most upvoted comments

So far so good. The solution seems to be:

  • in all Fragments, the Views must be nulled in onDestroyView (which is already the case in BaseSampleFragment because of an old memory leak issue #335)
  • a good practice seems to call the super statement last in onDestroyView

As there are about 140 Fragments in the demo app, the fix is not going to be instant (though it’s easy). I’m working on it.