fix: set currentInput
to nil
to fix a memory leak
#323
+1
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📜 Description
Set
currentInput
tonil
to fix a memory leak.💡 Motivation and Context
If we store a reference as
currentInput = UIResponder.current
, then even if view is removed from the screen the view will not be deallocated (because we have a strong reference) and it'll be kind of memory leak (because view should be deallocated and free up a memory).To fix this problem we need to remove a reference so ARC (automatic reference counter) will work properly and will deallocate view.
Actually it's not a very big problem, because users are switching between inputs frequently (and we overwrite a reference every time) so we have kind of have a constant memory allocation and it is not growing over time. Also we don't interact with this input anymore (don't call
becomeFirstResponder
and other methods), so it's kind of "safe".📢 Changelog
iOS
currentInput
tonil
inkeyboardWillHide
handler;🤔 How Has This Been Tested?
Tested on iPhone 15 Pro (iOS 17.2) + e2e tests.
📸 Screenshots (if appropriate):
📝 Checklist