Reference that makes memory leak
Describe the bug Since version 7.0.0. (also with the latest version 7.0.2) IQKeyboardManager instance holds reference to the last focused text field even keyboard is dismissed, which makes memory leak and side effects on host application (as in my case). With version 6.5.16 no such issues.
To Reproduce Steps to reproduce the behavior: Initialize IQKeyboardManager in AppDelegate
IQKeyboardManager.shared.enable = true
IQKeyboardManager.shared.enableAutoToolbar = false
IQKeyboardManager.shared.resignOnTouchOutside = true
Ensure the text field is the focus and dismiss the keyboard. Transition to another ViewController, ensuring it's not retained in the navigation stack. Although the specific ViewController is no longer part of the view hierarchy, it remains in the memory graph, which causes a memory leak and in my case app side effects.
Expected behavior If keyboard is dismissed it shoudn't hold any reference to input fields.
Screenshots
Here is the memory graph:
Demo Project n/a
Versions
Xcode: 15.3 Mac OS: 14.4.1 Simulator/Device: both on simulator and device Simulator/Device Name: iPhone 15 Library Version: 7.0.0./ 7.0.1./ 7.0.2.
Additional context n/a
Thanks for reporting this issue. I'll investigate it and see why this is happening.
IQKeyboardManager.shared.enable = true IQKeyboardManager.shared.enableAutoToolbar = false IQKeyboardManager.shared.resignOnTouchOutside = true
+1
@hackiftekhar any news on this?
I had the same problem
+1
Same problem
+1 I have the same problem. It holds any view controller with a UITextField in memory even after the view controller was popped.
@hackiftekhar maybe you have any updates?
I have tried to fixed the issue and pushed the code to master branch. However haven't tested my changes in different scenarios. So I would like to ask you guys to test the master branch version to see if you are able to still reproduce memory leaks in your situations and also test if everything works well for you. Till then I would like to keep this issue open.
@hackiftekhar version 7.1.1 solved my problem, my problem was when setting the textfield to beFirstResponder, which causes a memory leak, thank you
Thanks @Sukarma33 for notifying that your problem is solved.
I had the same problem, just hide keyboard before dismissing ViewController, it helped for me 😊
The issue is still there, even with version 7.1.1
Someone else also has the same issue, so I'll leave this ticket closed.
https://github.com/hackiftekhar/IQKeyboardManager/issues/2055
I tried to fix it with some weak referencing and handled some pop gesture cases. Can you guys check master branch and see if issue is still there.