Skip to content

Memory leak in DiscoveryNavigator #41

@tohyuon

Description

@tohyuon

I noticed a memory leak in the DiscoveryNavigator class.

The DiscoveryNavigator class contains the static field "views" with a list of ViewCache objects.
This list gets initialized in the initViews method that is invoked by the constructor.

The ViewCache class is a non-static embedded class of the DiscoveryNavigator, which means that it keeps an implicit reference to the containing (DiscoveryNavigator) instance.

Due to the static field and the implicit reference, the very first DiscoveryNavigator instance will never become garbage collected.
Since the Navigator also keeps a reference to the UI instance, this means that the UI instance and all its referenced objects cannot be garbage collected either.

(static field DiscoveryNavigator.views -> List of DiscoveryNavigator.ViewCache instances -> DiscoveryNavigator instance -> UI instance)

The solution to this issue is to declare the embedded ViewCache class static.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions