title: ExoPlayer occupying memory even after releasing
body: <p>In the main activity of my app, I show a number of cards to user. when he clicks on any of them, a fragment is opened which contains a <code>ViewPager2</code>. The fragments inside the viewPager2 each contains an <code>ExoPlayer</code> and plays a related video when resumed.</p>
  <p>When the user clicks on back button, the fragment must be closed and release all its children (including viewPager2 and its fragments, and exoPlayers). In order to release exoPlayers, I use the following code in <code>OnDestroyView()</code> of the viewPager2 fragments:</p>
  <pre><code>@Override
  public void onDestroyView() {
      super.onDestroyView();
  
      try {
          if (player != null &amp;&amp; listener != null) {
              player.removeListener(listener);
              player.release();
              player = null;
          }
  
          if (playerView != null)
              playerView.setPlayer(null);
  
          dashMediaSource = null;
          progressiveMediaSource = null;
          playerView = null;
          listener = null;
      } catch (Exception ignored) {
      }
  }
  </code></pre>
  <p><strong>after that, I ran Android Studio profiler to check app heap and I noticed some objects related to exoPlayer are still in memory:</strong></p>
  <p><a href="https://i.stack.imgur.com/2AWdx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2AWdx.jpg" alt="enter image description here" /></a></p>
  <p>Now the question is are I making a mistake in releasing the memory and specifically exoPlayers? If not why these objects are still in RAM and how to get rid of them?</p>