CS FundamentalsHardProduct-company placement

A UI component subscribes to a long-lived event bus in its constructor but never unsubscribes. Screens using it are opened and closed many times, and memory keeps growing. What is the cause?

  1. A. The Observer pattern always leaks memory
  2. B. The 'lapsed listener' problem: the subject still holds references to the closed components, so they cannot be garbage-collected
  3. C. The event bus is a Singleton, which cannot be garbage-collected
  4. D. Too many notifications fill the call stack

Correct answer: B. The 'lapsed listener' problem: the subject still holds references to the closed components, so they cannot be garbage-collected

A subject's listener list is a strong reference; until components detach (or weak references are used), every closed screen stays reachable. Unsubscribing on dispose is the fix.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic