title: App crashes with low memory only on iPhone 8 iOS 14.4.1
body: <p>I am facing a weird error.</p>
  <p>I have below method called on tapping a label. The method hides UIDatePicker. This is in UIViewController presented from collection view or table view.</p>
  <p>this is in viewDidLoad()</p>
  <pre><code>self.StartDateLabel.addGestureRecognizer(UITapGestureRecognizer(target:self, action:#selector(self.startDateLabelTapped(_:))))
  </code></pre>
  <p>and this is the method called.Tapping the label first time shows the date picker so selector works but tapping again causes the issue. This happens on iPhone 8 only. I have tested on iPhone 11, 8 Plus. This is consistent behaviour.</p>
  <p>I have one more such label for another date picker and same happens on that too.</p>
  <p>What could be the reason?</p>
  <pre><code>@objc private func startDateLabelTapped(_ sender: Any) {
          
          if self.startDatePicker.isHidden {
      
              UIView.animate(withDuration: 0.3, delay: 0, options: [.transitionFlipFromLeft]) {
      
                  DispatchQueue.main.async {
      
      
                      self.startDatePicker.isHidden = false
                  }
              } //end of UIView.animate
          } else {
      
              UIView.animate(withDuration: 0.3, delay: 0, options: [.transitionFlipFromRight]) {
      
                  DispatchQueue.main.async {
                      self.startDatePicker.isHidden = true //after this memory usage goes high and app crash with below stacktrace.
      
                  }
              } //end of UIView.animate
      
          }
      }
  
  Fatal Exception: NSInvalidArgumentException
  0  CoreFoundation                 0x1818499d8 __exceptionPreprocess
  1  libobjc.A.dylib                0x195bcfb54 objc_exception_throw
  2  CoreFoundation                 0x181759bbc -[NSOrderedSet initWithSet:copyItems:]
  3  UIKitCore                      0x1840e8d30 -[UIResponder doesNotRecognizeSelector:]
  4  CoreFoundation                 0x18184c01c ___forwarding___
  5  CoreFoundation                 0x18184df8c _CF_forwarding_prep_0
  6  CoreFoundation                 0x1817ac370 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
  7  CoreFoundation                 0x1817ac330 ___CFXRegistrationPost_block_invoke
  8  CoreFoundation                 0x1817ab928 _CFXRegistrationPost
  9  CoreFoundation                 0x1817ab320 _CFXNotificationPost
  10 Foundation                     0x1829e10a0 -[NSNotificationCenter postNotificationName:object:userInfo:]
  11 Foundation                     0x182a62fa8 -[NSUbiquitousKeyValueStore _postDidChangeNotificationExternalChanges:sourceChangeCount:]
  12 Foundation                     0x182be31e0 __53-[NSUbiquitousKeyValueStore _syncConcurrentlyForced:]_block_invoke_2
  13 libdispatch.dylib              0x181481298 _dispatch_call_block_and_release
  14 libdispatch.dylib              0x181482280 _dispatch_client_callout
  15 libdispatch.dylib              0x1814645b0 _dispatch_main_queue_callback_4CF$VARIANT$armv81
  16 CoreFoundation                 0x1817c95e0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
  17 CoreFoundation                 0x1817c3a88 __CFRunLoopRun
  18 CoreFoundation                 0x1817c2ba0 CFRunLoopRunSpecific
  19 GraphicsServices               0x19852b598 GSEventRunModal
  20 UIKitCore                      0x1840b42f4 -[UIApplication _run]
  21 UIKitCore                      0x1840b9874 UIApplicationMain
  22 Lendable-Test                  0x10524ef38 main + 99 (AppDelegate.swift:99)
  23 libdyld.dylib                  0x1814a1568 start
  </code></pre>
  <p>have checked with print statement after isHidden that the method is called. No app specific code is executed after it and The memory jumps executing some internal code. I can’t catch using breakpoint also as app crash due to memory.</p>
  <p>Three screenshots from Instruments. I dont know how to analyse this data</p>
  <p><a href="https://i.stack.imgur.com/LwYDD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LwYDD.png" alt="enter image description here" /></a>
  <a href="https://i.stack.imgur.com/VkRgu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VkRgu.png" alt="enter image description here" /></a></p>
  <p>memory leak
  <a href="https://i.stack.imgur.com/ECG4c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ECG4c.png" alt="enter image description here" /></a></p>
  <p>I get this stack trace when i pause just before memory tops out. Strangely my app works fine on iPhone 8 simulator but fails only on device !! I save added stack trace. i don't know why collection view related code is executed when i hide a control on another view.</p>
  <pre><code>#0  0x0000000195bcb498 in objc_msgSend ()
  #1  0x00000001837a5d3c in __68-[NSCollectionLayoutSize _effectiveSizeForContainer:ignoringInsets:]_block_invoke ()
  #2  0x00000001837a5c44 in -[NSCollectionLayoutSize _effectiveSizeForContainer:ignoringInsets:] ()
  #3  0x00000001837d07a4 in -[_UICollectionLayoutItemSolver layoutFrame] ()
  #4  0x00000001837d6ff0 in -[_UICollectionSolutionGroupArrangementItem initWithSolution:] ()
  #5  0x00000001837d1764 in -[_UICollectionLayoutItemSolver _solveGroup] ()
  #6  0x00000001837d0c64 in -[_UICollectionLayoutItemSolver _solveForContainer:layoutAxis:traitCollection:maxFrameCount:layoutRTL:preferredSizes:solutionRecursionDepth:] ()
  #7  0x00000001837d1648 in -[_UICollectionLayoutItemSolver _solveGroup] ()
  #8  0x00000001837d0c64 in -[_UICollectionLayoutItemSolver _solveForContainer:layoutAxis:traitCollection:maxFrameCount:layoutRTL:preferredSizes:solutionRecursionDepth:] ()
  #9  0x00000001837cf92c in -[_UICollectionLayoutItemSolver solveForContainer:layoutAxis:traitCollection:maxFrameCount:layoutRTL:preferredSizes:] ()
  #10 0x00000001837cf89c in -[_UICollectionLayoutItemSolver solveForContainer:layoutAxis:traitCollection:maxFrameCount:layoutRTL:] ()
  #11 0x00000001837df388 in -[_UICollectionLayoutSectionFixedSolver _solve] ()
  #12 0x00000001837bb1a0 in -[_UICollectionCompositionalLayoutSolver _solveWithSectionLayouts:preferredSizesDict:dataSourceSnapshot:update:] ()
  #13 0x00000001837bac24 in -[_UICollectionCompositionalLayoutSolver _solve] ()
  #14 0x00000001837b5944 in -[_UICollectionCompositionalLayoutSolver resolveForContainerChange:] ()
  #15 0x00000001837acf68 in -[UICollectionViewCompositionalLayout _boundsChangeResolve] ()
  #16 0x00000001837aaaec in -[UICollectionViewCompositionalLayout invalidateLayoutWithContext:] ()
  #17 0x0000000183832f00 in -[UICollectionView _invalidateLayoutForUpdatedLayoutMarginsIfNeeded] ()
  #18 0x0000000183832dc8 in -[UICollectionView layoutMarginsDidChange] ()
  #19 0x0000000184592374 in -[UIView _layoutMarginsDidChangeFromOldMargins:] ()
  #20 0x0000000184592acc in -[UIView _updateInferredLayoutMarginsFromSuperview:] ()
  #21 0x00000001845a50c4 in -[UIView(Geometry) setBounds:] ()
  #22 0x0000000184533548 in -[UIScrollView setBounds:] ()
  #23 0x0000000183832474 in -[UICollectionView setBounds:] ()
  #24 0x00000001845a43b0 in -[UIView(Geometry) _applyISEngineLayoutValuesToBoundsOnly:] ()
  #25 0x00000001845a4790 in -[UIView(Geometry) _resizeWithOldSuperviewSize:] ()
  #26 0x00000001844c8184 in -[UIScrollView(_UIOldConstraintBasedLayoutSupport) _resizeWithOldSuperviewSize:] ()
  #27 0x00000001845a3c8c in __46-[UIView(Geometry) resizeSubviewsWithOldSize:]_block_invoke ()
  #28 0x00000001817cd1d0 in __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ ()
  #29 0x0000000181731478 in -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] ()
  #30 0x00000001845a3be8 in -[UIView(Geometry) resizeSubviewsWithOldSize:] ()
  #31 0x00000001844d619c in -[UIView(AdditionalLayoutSupport) _is_layout] ()
  #32 0x00000001845ab8ac in -[UIView _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] ()
  #33 0x0000000183cff4e8 in -[_UIDatePickerCalendarDateView layoutSubviews] ()
  #34 0x00000001845be398 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
  #35 0x0000000184ac3df4 in -[CALayer layoutSublayers] ()
  #36 0x0000000184aca398 in CA::Layer::layout_if_needed(CA::Transaction*) ()
  #37 0x0000000184ad56e8 in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
  #38 0x0000000184a20d7c in CA::Context::commit_transaction(CA::Transaction*, double, double*) ()
  #39 0x0000000184a4af40 in CA::Transaction::commit() ()
  #40 0x0000000184a4c1f0 in CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) ()
  #41 0x00000001817c887c in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
  #42 0x00000001817c2f50 in __CFRunLoopDoObservers ()
  #43 0x00000001817c3498 in __CFRunLoopRun ()
  #44 0x00000001817c2ba0 in CFRunLoopRunSpecific ()
  #45 0x000000019852b598 in GSEventRunModal ()
  #46 0x00000001840b42f4 in -[UIApplication _run] ()
  #47 0x00000001840b9874 in UIApplicationMain ()
  #48 0x000000010325aef0 in main at /Users/ashishn/Documents/Developer/XCode Projects/YOVL-Xcode/Source/AppDelegate.swift:99
  #49 0x00000001814a1568 in start ()
  </code></pre>