---
title: "Discussion on \"A Subtle Memory Leak - Fragment, RecyclerView and its Adapter\" | Hashnode"
description: "Discussion on \"A Subtle Memory Leak - Fragment, RecyclerView and its Adapter\". Oh the Fragment\nFragments are amazing: modular, reusable, own view layout, swappable, you name them. However, you need to be extra careful when it comes to dealing with their lifecycle. I mean the lifecycle diagram clearly depicts the number of callb..."
url: "https://hashnode.com/posts/a-subtle-memory-leak-fragment-recyclerview-and-its-adapter/5e74b6b6bc8844135ba516cd"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [A Subtle Memory Leak - Fragment, RecyclerView and its Adapter](https://charlesmuchene.com/a-subtle-memory-leak-fragment-recyclerview-and-its-adapter?utm_source=hashnode&utm_medium=feed)

Oh the Fragment Fragments are amazing: modular, reusable, own view layout, swappable, you name them. However, you need to be extra careful when it comes to dealing with their lifecycle. I mean the lifecycle diagram clearly depicts the number of callb...

Mar 20, 2020 · charlesmuchene.com  
Read the article

-   [#android](https://hashnode.com/tag/android)

## Written by

[Charles Muchene](https://hashnode.com/@charlesmuchene)

@charlesmuchene · Austin, TX

  
[View profile](https://hashnode.com/@charlesmuchene)

Software Engineer

Software Engineer

## Responses 1

Markdown supported · ⌘↵ to post

[Kennedy Odife](https://hashnode.com/@odifek)

[Apr 4, 2020](https://hashnode.com/posts/a-subtle-memory-leak-fragment-recyclerview-and-its-adapter/5e74b6b6bc8844135ba516cd/comment/5e88ba122fcec10052c10124)

Nice article. What if you create the adapter locally inside onViewCreated? I think that will be good also

[Charles Muchene](https://hashnode.com/@charlesmuchene)

[Apr 26, 2020](https://hashnode.com/posts/a-subtle-memory-leak-fragment-recyclerview-and-its-adapter/5e74b6b6bc8844135ba516cd/comment/5e88ba122fcec10052c10124#reply-5ea50a400135fc417662f582)

That's all good if you have static data and all of it is available when `onViewCreated` finishes. I guess that should work.
