Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible false positive using AndroidReferenceMatchers.appDefaults #2717

Open
aperfilyev opened this issue Oct 8, 2024 · 0 comments
Open

Comments

@aperfilyev
Copy link

Description

Thank you for such an excellent library. We wrote our own JUnit rule for finding leaks using a UI Automator test, but we encountered a flaky error on our CI. It seems like FinalizerReference.zombie is not included there.

┬───
│ GC Root: System class
│
├─ java.lang.ref.FinalizerReference class
│    Leaking: NO (a class is never leaking)
│    ↓ static FinalizerReference.queue
│                                ~~~~~
├─ java.lang.ref.ReferenceQueue instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21748 objects
│    ↓ ReferenceQueue.head
│                     ~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21744 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21708 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21707 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21706 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21705 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21694 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21693 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21692 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21691 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21675 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21674 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21673 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21672 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21671 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21658 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21657 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21656 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21655 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21654 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21646 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21642 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21634 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21632 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21630 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21628 objects
│    ↓ Reference.queueNext
│                ~~~~~~~~~
├─ java.lang.ref.FinalizerReference instance
│    Leaking: UNKNOWN
│    Retaining 1,2 MB in 21626 objects
│    ↓ FinalizerReference.zombie
│                         ~~~~~~
├─ androidx.swiperefreshlayout.widget.SwipeRefreshLayout$6 instance
│    Leaking: UNKNOWN
│    Retaining 320 B in 11 objects
│    Anonymous subclass of android.view.animation.Animation
│    ↓ SwipeRefreshLayout$6.this$0
│                           ~~~~~~
├─ org.example.app.ui.widget.StickySwipeRefreshLayout instance
│    Leaking: YES (View.mContext references a destroyed activity)
│    Retaining 277,7 kB in 7768 objects
│    View not part of a window view hierarchy
│    View.mAttachInfo is null (view detached)
│    View.mWindowAttachCount = 1
│    mContext instance of org.example.app.feature.mainscreen.ui.main.MainActivity with mDestroyed = true
│    ↓ View.mContext
╰→ org.example.app.feature.mainscreen.ui.main.MainActivity instance
​     Leaking: YES (Activity#mDestroyed is true)
​     Retaining 621,8 kB in 6268 objects
​     mApplication instance of org.example.app.AndroidTestApp
​     mBase instance of androidx.appcompat.view.ContextThemeWrapper

Steps to Reproduce

  1. dump heap using -g flag
  2. run
HeapAnalyzer.analyze(
    heapDumpFile = file,
    graph = file.openHeapGraph(),
    leakingObjectFinder = FilteringLeakingObjectFinder(
        AndroidObjectInspectors.appLeakingObjectFilters
    ),
    referenceMatchers = AndroidReferenceMatchers.appDefaults,
    computeRetainedHeapSize = true,
    objectInspectors = AndroidObjectInspectors.appDefaults,
    metadataExtractor = AndroidMetadataExtractor
)

Expected behavior:

no leaks

Version Information

  • Shark version:2.14
  • Gradle version:8.10.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant