title: Memory leak in activity enter transition coordinator after shared element transition
body: <p>I'm having a problem with memory leak in <code>EnterTransitionCoordinator</code> while using shared element transitions. Below you can see the app structure:</p>
  
  <p><a href="https://i.stack.imgur.com/uqjNl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uqjNl.jpg" alt="App structure"></a></p>
  
  <p>It has 2 screens, first is an <code>Activity</code> with <code>DrawerLayout</code> and few <code>Fragment</code>s inside. One of them consists a list of photos and clicking specific photo triggers shared element transition to <code>Fragment</code> from <code>ViewPager</code> located in another <code>Activity</code>. I'm using custom <code>SharedElementCallback</code> when exiting and reentering these two <code>Activity</code>s for mapping a correct <code>View</code> for shared element transition. I based my code on this great blog post: <a href="https://android.jlelse.eu/dynamic-shared-element-transition-23428f62a2af" rel="nofollow noreferrer">https://android.jlelse.eu/dynamic-shared-element-transition-23428f62a2af</a></p>
  
  <p>The problem is, that after swiping between <code>ViewPager</code>'s items, <code>Fragment</code>s are being destroyed, but the <code>View</code> used for shared element transition is being kept in <code>Activity</code>'s <code>ActivityTransitionState</code>, specifically in <code>EnterTransitionCoordinator</code>. The same when reentering to <code>Activity</code> with <code>DrawerLayout</code> and then opening another <code>Fragment</code>. References to <code>View</code>s used for shared element transitions are still kept int <code>Activity</code>s even though <code>Fragment</code>s were destroyed, which causes a memory leak. </p>
  
  <p>My question: Is there a good way to avoid this memory leak?</p>