最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Android studio got a leak while I just new a fragment - Stack Overflow

programmeradmin3浏览0评论

when I new a fragment in an Activity, then I using the profiler to analyse the heap, stay in the current activity. but I got a leak warning which showed a fragment is leaked, is this a bug in profiler? the following picture is the capture

    private val f = Fragment()

I thought that the lifecycle of this fragment is shorter or equal than the activity, how can I get the leak?

when I new a fragment in an Activity, then I using the profiler to analyse the heap, stay in the current activity. but I got a leak warning which showed a fragment is leaked, is this a bug in profiler? the following picture is the capture

    private val f = Fragment()

I thought that the lifecycle of this fragment is shorter or equal than the activity, how can I get the leak?

Share Improve this question asked Mar 17 at 13:41 ahsiuahsiu 1231 silver badge6 bronze badges 1
  • I found some explains about this issue developer.android/studio/profile/… – ahsiu Commented Mar 17 at 17:06
Add a comment  | 

1 Answer 1

Reset to default 0

If you create a fragment without adding it to the activity using the fragment transaction manager it will show up as a false positive.

Found here:

https://developer.android/studio/profile/capture-heap-dump#find-memory-leaks

发布评论

评论列表(0)

  1. 暂无评论