Hubbry Logo
search button
Sign in
Lapsed listener problem
Lapsed listener problem
Comunity Hub
History
arrow-down
starMore
arrow-down
bob

Bob

Have a question related to this hub?

bob

Alice

Got something to say related to this hub?
Share it here.

#general is a chat channel to discuss anything related to the hub.
Hubbry Logo
search button
Sign in
Lapsed listener problem
Community hub for the Wikipedia article
logoWikipedian hub
Welcome to the community hub built on top of the Lapsed listener problem Wikipedia article. Here, you can discuss, collect, and organize anything related to Lapsed listener problem. The purpose of the hub...
Add your contribution
Lapsed listener problem

In computer programming, the lapsed listener problem is a common source of memory leaks for object-oriented programming languages, among the most common ones for garbage collected languages.[1]

It originates in the observer pattern, where observers (or listeners) register with a subject (or publisher) to receive events. In basic implementation, this requires both explicit registration and explicit deregistration, as in the dispose pattern, because the subject holds strong references to the observers, keeping them alive. The leak happens when an observer fails to unsubscribe from the subject when it no longer needs to listen. Consequently, the subject still holds a reference to the observer which prevents it from being garbage collected — including all other objects it is referring to — for as long as the subject is alive, which could be until the end of the application.

This causes not only a memory leak, but also a performance degradation with an "uninterested" observer receiving and acting on unwanted events. This can be prevented by the subject holding weak references to the observers, allowing them to be garbage collected as normal without needing to be unregistered.

References

[edit]
  1. ^ Memory Loiterers in Java, Ethan Henry and Ed Lycklama