question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Explicitly call `unbind()` in Activity if `ListenerClass` has valid `remover`???

See original GitHub issue

if ListenerClass implementation has a valid remover, e.g. OnPageChange and OnTextChanged, the remover method is added in the implementation of Unbinder.unbind() method, by BindingSet.removerOrSetter() method.

So, for Activities that reference ListenerClass implementations with a valid remover, I did not see a explicit or implicit method to call the unbind() method of ButterKnife.bind()'s return value.

I wonder if the remover or unbind() method would be automatically called? How if yes? If no, there would be memory leak.

I believe we MUST EXPLICITLY call Unbinder.unbind(), where Unbinder instance is returned by ButterKnife.bind(), in Activities referencing any ListenerClass with a valid remover.

#906 #971

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
JakeWhartoncommented, Apr 19, 2019

You only need to call unbind() in fragments in onDestroyView because it can cause a leak if the fragment is re-used. For activities you do not need to call the method because the references form a cycle which will be correctly GC’d.

0reactions
MihailsKuzminscommented, Apr 23, 2019

@JakeWharton thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Properly unbind service from activity - android - Stack Overflow
1 Answer 1 ... Call unbindService() on the same Context that you call bindService() on. Presumably, given the structure of your sample, you...
Read more >
Camera API | Android Developers
unlock() calls are managed for you automatically. Unlike taking pictures with a device camera, capturing video requires a very particular call order. You...
Read more >
30 Enabling ADF Security in a Fusion Web Application
Remove any grants to the test-all role for all ADF security-aware resources and replace with grants that you define. Because ADF resources are...
Read more >
feature-remove-limitations PDF - MicroEJ Documentation
When selected, this option enables a dump of the heap each time the System.gc() method is called by the MicroEJ. Application. . ....
Read more >
Web on Servlet Stack - Spring
DispatcherServlet. WebFlux. Spring MVC, as many other web frameworks, is designed around the front controller pattern where a central Servlet ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found