GestureDetector is leaky.
Nobody has claimed this yet.
- 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

Tested platform
- Android 6.0.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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