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?
- A. The Observer pattern always leaks memory
- B. The 'lapsed listener' problem: the subject still holds references to the closed components, so they cannot be garbage-collected
- C. The event bus is a Singleton, which cannot be garbage-collected
- 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.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- In GRASP terms, an Order aggregates its LineItems and has the data needed to initialise them. Which class should create LineItem objects…
- Assertion (A): Classes that call a Singleton through its global getInstance() are harder to unit-test. Reason (R): The dependency is…
- In the 2020 Scrum Guide each artifact has a commitment. Which pairing is correct?
- Midway through a sprint, a market change makes the Sprint Goal obsolete. According to the Scrum Guide, who can cancel the sprint?
- At the end of a sprint, one backlog item is coded but its automated tests, required by the Definition of Done, are not written. What does…
- A sprint commitment had stories of 8, 5, 5, 3 and 3 points. At the sprint's end the 8, one 5 and both 3s meet the Definition of Done; the…