title: How to destroy a dialog fragment completely for memory leak issue?
body: <p>I Have a empty dialog fragment. For get memory leak issue, I Add <strong>LeakCanary</strong> library to my app. When open dialog fragment with this commands:</p>
  
  <pre><code>DialogFragment fragment = TabsFragment.newInstance();
  fragment.setStyle(DialogFragment.STYLE_NO_FRAME, R.style.DialogFragments);
  fragment.show(getSupportFragmentManager(), "MyFragment");
  </code></pre>
  
  <p>and close it, LeakCanary show me this Error:</p>
  
  <p><a href="https://i.stack.imgur.com/M8CGs.jpg" rel="nofollow noreferrer">ScreenShot</a></p>
  
  <p>I try and add <em>setRetainInstance</em> in <strong>OnCreate</strong> method and <em>view = null</em> in <strong>onDestroyView</strong>. But that memory leak error still showing.</p>
  
  <p>This is my Fragment:</p>
  
  <pre><code>public class TabsFragment extends DialogFragment {
  
  private View view;
  
  public static TabsFragment newInstance() {
      return new TabsFragment();
  }
  
  @Override
  public void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setRetainInstance(true);
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, final ViewGroup container,
                           Bundle savedInstanceState) {
      view = inflater.inflate(R.layout.my_fragment, container, false);
      return view;
  }
  
  @Override
  public void onDestroyView() {
      super.onDestroyView();
      dismiss();
      view = null;
  }
  }
  </code></pre>
  
  <p>How to fix this issue?</p>