← Quiz: Observer, Strategy and Decorator: all 10 questions
Quiz: Observer, Strategy and Decorator · Question 9 of 10
What is a common bug when using the Observer pattern in long-running apps?
What is a common bug when using the Observer pattern in long-running apps?
- A.Observers run before the subject is created
- B.The subject cannot have more than one observer
- C.Observers that are never unsubscribed stay in the list and cannot be garbage collected
- D.Lambdas cannot be used as observers
Answer & explanation
Correct answer: Observers that are never unsubscribed stay in the list and cannot be garbage collected
The subject's list keeps a reference, so forgotten observers leak memory.
Can you get the rest right without peeking?
Take the timed Quiz: Observer, Strategy and Decorator quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →