libgdx / libgdx/libgdx

GestureDetector is leaky.

Open
#4,651 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug input
Dominant language
Java
Stars
25.4k
Forks
6.5k
Avg merge
1d 16h
Merged PRs (30d)
5

Description

Issue details

GestureDetector instances are not collected by GC

Reproduction steps/code

2 activities, one creates another with a child activity instantiating gdx.Game where GestureDetector also instantiated. Close the child activity and return to the parent after triggering some gestures. Repeat from creating another child activity.
From the .hprof files you can see that GestureDetector instances are never collected with a Timer (longPressTask) being the reason. It's never disposed.
I made a copy of GestureDetector in my project and removed longPressTask since I don't use it, after that GC works as expected.

Version of LibGDX and/or relevant dependencies

1.9.6

Memory snapshot

Dump screenshot

Tested platform
  • Android 6.0.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating GestureDetector and inspecting how longPressTask is created and released during activity teardown. Reproduce the Android activity sequence with a memory snapshot, then verify that GestureDetector instances and their Timer tasks are collectible after the child activity closes.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
game-dev, mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.