All challenges
Multiple ChoiceIntermediate 45s

shared_ptr cycle leak

Two objects hold `shared_ptr` to each other. Why do they leak, and what fixes it?
Options
  1. 1They do not leak; shared_ptr detects cycles and frees them.
  2. 2The reference counts never reach zero; break one direction with a weak_ptr.
  3. 3They leak only if make_shared was not used; call reset() on both to fix.
  4. 4They leak because shared_ptr is not thread-safe; use a mutex.

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle