[FIX] retain-cycle memory leak issue solved. #24
Merged
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.
Some critical closure retain-cycle causing memory leak issues were fixed where scrollDelegate and textFieldTarget capture closure making strong reference.
To give background story a little in advance,
I am using my own customization based on reel-search for application that will be released V1.0 soon :) (named : 'All Dayz')
Thank you for the awesome repository and I am very glad to try pull request to this.
To explain the pull request,
I fixed some critical memory leak issues caused by closure memory retain cycle.
It can be very easily reproduced if instead of existing sample example using Single ViewController, we use root-navigation controller having ViewController1 and push ViewController2 having reel-search and back to VC1.
Using navigation controller, if we test push and pop current single ViewController example, memory is not released after pop. for example, it increases more than like 500MB after push and pop 3 times since data.txt is huge data set.
That means, this memory leak issue occurs in real project unavoidably except for the case where we only use single VC app having reel-search.
Below is the memory leak cases where I push and pop 3 times current reel-search example.
FYI, Memory leak retain cycles cases are categorized as 2 group as below attached :
![2018-08-29 23 33 55](https://user-images.githubusercontent.com/6975179/44798162-d4c2ca80-abeb-11e8-8325-9156bc3e6dbe.png)
(1) TextFieldTarget, NotificationCallbackWrapper case
(2) ScrollDelegate case
![2018-08-29 23 11 25](https://user-images.githubusercontent.com/6975179/44798183-df7d5f80-abeb-11e8-8a16-356bc9ff7ba4.png)
I resolved these retain cycles and result is below with same test case above.
![2018-08-30 00 44 42](https://user-images.githubusercontent.com/6975179/44799094-181e3880-abee-11e8-86c9-4ec5eb28263e.png)
I hope it helps, Thank you!