I have a fragment which keeps reference to the parent activity. On onCreateView method I initialise the adapter by passing a static list to the adapter. As the list is "static", does it mean that the Activity, Fragment and Adapter will never be garbage collected?
Here is my code -
public class MyFragment extends Fragment
{
RecyclerView rvMyContestLists;
MyContestListAdapter adapter = null;
Activity activity;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
// CConstantVariables.listMyContestData is static
adapter = new MyContestListAdapter(activity, CConstantVariables.listMyContestData);
rvMyContestLists.setAdapter(adapter);
rvMyContestLists.setLayoutManager(new LinearLayoutManager(getActivity()));
}
}
Does using "static" variable CConstantVariables.listMyContestData as adapter's list data mean that the Activity will never be Garbage collected? Does this code indicates memory leak?